From 33649a188a6699e0bc019a72d04ee0718ace4d81 Mon Sep 17 00:00:00 2001 From: Pallaav Sethi Date: Fri, 15 Oct 2021 00:19:56 +0530 Subject: [PATCH 1/2] Added a C program to convert binary to decimal --- C/Binary to Decimal.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C/Binary to Decimal.c diff --git a/C/Binary to Decimal.c b/C/Binary to Decimal.c new file mode 100644 index 0000000..fedeff5 --- /dev/null +++ b/C/Binary to Decimal.c @@ -0,0 +1,16 @@ +#include +#include + main() +{ + int i=0,n,re,num=0; + printf("Enter the binary number:"); + scanf("%d",&n); + while(n>0) + { + re=n%10; + num=num+re*pow(2,i); + i++; + n=n/10; + } + printf("The decimal number =%d",num); +} From c1ae06bc296b54ba0b4fe9ace89be3675acd32c9 Mon Sep 17 00:00:00 2001 From: Pallaav Sethi Date: Tue, 26 Oct 2021 23:41:48 +0530 Subject: [PATCH 2/2] Added Round Robin Algorithm --- C/round_robin.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 C/round_robin.c diff --git a/C/round_robin.c b/C/round_robin.c new file mode 100644 index 0000000..d2b8cc2 --- /dev/null +++ b/C/round_robin.c @@ -0,0 +1,118 @@ +#include +#include +void rr(int,int,int[],int[]); +void srtf(); +void main() +{ +int n,tq,choice; +int bt[10],st[10],i,j,k; +for(;;) +{ +printf("Enter the choice\n"); +printf("1) Round Robin\n 2) SRT \n 3) Exit\n"); +scanf("%d", &choice); +switch(choice) +{ +case 1: printf("Round Robin scheduling algorithm\n"); +printf("Enter the number of process\t"); +scanf("%d",&n); +printf("Enter the burst time for sequences\n"); +for(i=0;itq) +st[i]=st[i]-tq; +else if(st[i]>=0) +{ +temp1=st[i]; +st[i]=0; +} +sq=sq+temp1; +tat[i]=sq; +} +if(n==count) +break; +} +for(i=0;i0) +{ +smallest = i; +} +} +rt[smallest]--; +if(rt[smallest]==0) +{ +remain++; +endtime=time+1; +j=smallest; +printf("p[%d]\t|\t%d\t|\t%d\n",smallest+1,endtime-bt[j]-st[j],endtime-st[j]); +swt+=endtime-bt[j]-st[j]; +stat+=endtime-st[j]; +} +} +float awt=0.0, atat=0.0; +awt=(float)swt/n; +atat=(float)stat/n; +printf("Avg waiting time:%f\n",awt); +printf("Avg turnaround time:%f\n",atat); +} \ No newline at end of file