//can someone debug this program,,, thanks,,,

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#define N  100
struct processors      //PROCESS ATTRIBUTES//
  {
   float burst;
   float arrival;
   int priority;
   int num;
  }p[20],temp;
   struct ssss
 {
  int no;
  int xx;
  float arr;
  float burst;
  float ww;
  int pri;
  float wait;
 }process[N];

void main()
{

 void roundrobin(int);
{
 //void graphics(float *,float,int);
 int i,j,c,n;float left,right,top,bottom;
 /* select a driver and mode that supports */
   /* multiple background colors.            */
   int gdriver = EGA, gmode = EGAHI, errorcode;
   int bkcol, maxcolor, x, y;
   char msg[80];

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
		   printf("Graphics error: %s\n", grapherrormsg(errorcode));
		   printf("Press any key to halt:");
		   getch();
		   exit(1); /* terminate with an error code */
   }

 cleardevice();//Gets the input from the user//
 printf("ENTER THE NUMBER OF PROCESSES:\t");
 scanf("%d",&n);
 for(i=0;i<n;i++)
  {
		 gotoxy(22,2);
		 printf("PROCESS:%d\n",i+1);
		 printf("BURST TIME :\t");
		 scanf("%f",&p[i].burst);
		 printf("ARRIVAL TIME :\t");
		 scanf("%f",&p[i].arrival);
		 printf("PRIORITY :\t");
		 scanf("%d",&p[i].priority);
		 p[i].num = i+1;
		 if(p[i].arrival < 0 || p[i].burst <=0 || p[i].priority > n || p[i].burst> 40)
		  {
		    printf("\n\nINVALID INPUT\n");
		    printf("PLEASE RE ENTER THE PARAMETERS FOR PROCESS %d",i+1);
		    i--;
		    getch();
		  }
		  cleardevice();

  }
  for(i=0;i<n;i++)
   {
    for(j=i;j<n;j++)
     {
       if(p[i].arrival > p[j].arrival)
		  {
		    temp = p[i];
		    p[i] = p[j];
		    p[j] = temp;
		  }
     }
   }


void roundrobin(int n)
{
  int i,j,l=0,pr[30];float tot[10]={1,1,1,1,1,1,1,1,1,1},s[10]={0,0,0,0,0,0,0,0,0,0},c=1,y=0;
  float q,awt,total=0,wt[10]={0,0,0,0,0,0,0,0,0,0},g[400];
  void graphics(float *,float,int,float *,int,int *,int);
  cleardevice();
  printf("Enter the time quantum:  ");
  scanf("%f",&q);
  for(i=0;i<n;i++)
   {
		 tot[i] = p[i].burst;
   }
   g[y++] = total;
  g[y++] = 0;
  g[y++] = total = total + p[0].arrival;
  while(c<=n) //Keeps track of the processes that are completed
  {
  for(i=0;i<n;j++)//Performs the round robin function
   {
   if(tot[i]>0)  //Checks whether the process is over or not
   {
     tot[i] = tot[i] - q; //decreases the burst time by the
						   //time quantum
     if(tot[i]<=0)     // checks whether this is the last
				       //round for this process
		   {
		 g[y++] = p[i].num;
		 g[y++] = total = total + tot[i] + q;
		 //calculates the waiting time of the proces
		 wt[i] = total - p[i].burst - p[i].arrival;
    //checks whether a process has arrived in the mean time
		 if(total>=p[i+1].arrival)
		  {
		   i++;
		  }
		 else
		  {
		   i=0;
		  }
		 c++;
   }
     else
      {
       g[y++] = p[i].num;
       g[y++] = total = total + q;
       while(tot[i+1]<=0)//increments 'i' till it reaches an incomplete
		 i++;		 		  //process

		 if(total>=p[i+1].arrival)
		  {
		   i++;
		  }
       else
		  {
		   i=0;
		  }
      }
    }
   else
    {
     i++;
		  if(p[i].arrival > total) //checks for idle time
      {
		    if(i<=n)
				  {
				      g[y++] = 0;
						  g[y++] = total = p[i].arrival;

				  }
		    else if(i==n-1 && c==n-1)
				  {
						 g[y++] = 0;
				     g[y++] = total = p[i].arrival;

				  }
		   }
    }
   }
  }
  g[y++] = p[i-1].num;
  q=0;
 for(i=0;i<n;i++)  //calculates average waiting time
   {
   //printf("%d. %f\n",p[i].num,wt[i]);
   q = q + wt[i];
   }
   awt = q/n;
 graphics(wt,awt,n,g,y,pr,l);
 outtextxy(200,0,"FOR ROUND ROBIN SCHEDULING");
 getch();
 }
 void graphics(float *wt,float awt,int n,float *g,int y,int *pr,int l)
 {
   int i,msg1=0,j=0,u=0;
   char msg[30];
   float left,right,top,bottom,awd=0,turn=0,d=0;
   getch();
   cleardevice();
   setlinestyle(4, 1, 1);
  setfillstyle(10,1);
  bar3d(0,0,620,340,0,0);
   line(0, 2, 618, 2);
  line(2,2,2,338);
  line(2,338,618,338);
  line(618,338,618,2);
   setlinestyle(0,1,1);
   left = 0;
   top = 40;
   bottom = 80;
   right = 15;
   for(i=0;i<y;i++)
		 {
		  left = right;
		  right = *(g+i);
		  right = (15-j) * (right - u);
		  bar3d(left,top,right,bottom,0,0);
		  sprintf(msg,"%2.1f",*(g+i));
		  outtextxy(right,(82+msg1),msg);
		  i++;
		  setfillstyle(1,*(g+i));
		  if(right>=600)
		   {
		    right = 0;
		    top = 120;
		    bottom = 160;
		    msg1 = 82;u= *(g+i-1);
		    i--;
		    outtextxy(right,164,msg);
		    i++;
		   }
		  delay(500);
		 }
   setcolor(CYAN+BLINK);
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 0);
   sprintf(msg,"AVERAGE WAITING TIME : %f",awt);
   outtextxy(20,30,msg);
   for(i=0;i<n;i++)
		 {
		  d = d + p[i].burst;
		 }
   awd = d/n;
   turn = awd + awt;
   //settextstyle(DEFAULT_FONT, HORIZ_DIR, 4);
   sprintf(msg,"AVERAGE TURN AROUND TIME : %f",turn);
   outtextxy(300,30,msg);
   setcolor(WHITE);
   sprintf(msg,"PROCESS");
   outtextxy(32,210,msg);
   sprintf(msg,"WAITING TIME");
   outtextxy(190,210,msg);
   outtextxy(340,210,"COLORS");
   outtextxy(410,210,"IDLE");
   setfillstyle(1,0);
   bar3d(455,206,515,216,0,0);
   for(i=0;i<n;i++)
   {
   sprintf(msg,"%d.",p[i].num);
   outtextxy(48,226+(i*17),msg);
   sprintf(msg,"%f",*(wt+i));
   outtextxy(208,226+(i*17),msg);
   if(i==6)
		 break;
   }
   //getch();
   //cleardevice();
   /*for(i=7;i<n;i++)
   {
   sprintf(msg,"%d.",p[i].num);
   outtextxy(48,226+((i-7)*17),msg);
   sprintf(msg,"%f",*(wt+i));
   outtextxy(208,226+((i-7)*17),msg);
   } */
   for(i=0;i<n;i++)
   {
		 setfillstyle(1,p[i].num);
		 bar3d(330,225+(i*17),390,235+(i*17),0,0);
		 if(i==6)
		 break;
   }
   settextstyle(TRIPLEX_FONT, HORIZ_DIR,2 );
   outtextxy(50,0,"GANTT CHART");
   if(n>=7)
   {
   getch();
   cleardevice();
   settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
   sprintf(msg,"PROCESS");
   outtextxy(32,10,msg);
   sprintf(msg,"WAITING TIME");
   outtextxy(190,10,msg);
   outtextxy(340,10,"COLORS");
   outtextxy(410,10,"IDLE");
   setfillstyle(1,0);
   bar3d(455,6,515,16,0,0);
   for(i=7;i<n;i++)
   {
   sprintf(msg,"%d.",p[i].num);
   outtextxy(48,26+((i-7)*17),msg);
   sprintf(msg,"%f",*(wt+i));
   outtextxy(208,26+((i-7)*17),msg);
   }
   for(i=7;i<n;i++)
   {
		 setfillstyle(1,p[i].num);
		 bar3d(330,25+((i-7)*17),390,35+((i-7)*17),0,0);
   }
   }
   getch();
}

Again, add your code tags, explain your problem and this is a C program not a C++ program, so post it under the correct forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.