1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

declaration syntax error in main ()

Discussion in 'C' started by newuserme, Nov 30, 2011.

  1. newuserme

    newuserme New Member

    Joined:
    Nov 30, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    hey everyone ,m trying to do a program that displays the Olympic symbols using bresenham's algorithm but i keep getting declaration syntax error in main,pls help
    i can't see any problem with it

    Code:
    #include<iostream.h>
      #include<graphics.h>
      #include<conio.h>
      #include<math.h>
      #include<stdlib.h>
      #include<stdio.h>
    
         void circlePlotPoints(int xc,int yc,int x,int y)
    
    
      int  main()
    
       {
    
          int gd=DETECT,gm;
           initgraph(&gd,&gm,"");
          clrscr();
    
          setbkcolor(WHITE);
    
        setcolor(CYAN);
        drawCircle(100,100,35);
    
       setcolor(BLUE);
       drawCircle(175,100,35);
    
       setcolor(RED);
       drawCircle(250,100,35);
    
       setcolor(YELLOW);
       drawCircle(140,150,35);
    
       setcolor(GREEN);
       drawCircle(210,150,35);
    
    
        void circlePlotPoints(int xc,int yc,int x,int y)
       {
        putpixel(xc+x,yc+y,1);
        putpixel(xc-x,yc+y,1);
        putpixel(xc+x,yc-y,1);
        putpixel(xc-x,yc-y,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc+x,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc-x,1);
        putpixel(xc+y,yc-x,1);
        }
    
    
        void drawCircle (int xc,int yc,int radius)
        {
           int x=0;
          int y=radius;
          int p=1-radius;
    
        circlePlotPoints(xc,yc,x,y);
    
        while(x<=y)
        {
          x++;
          if(p<0)
    
            p=p+2*x+1;
    
          else
           {
            y--;
            p =p+2*(x-y)+1;
          }
           circlePlotPoints(xc,yc,x,y);
         }
    
       getch();
    
       }
     return 0;
        }
     
    Last edited by a moderator: Nov 30, 2011
  2. newuserme

    newuserme New Member

    Joined:
    Nov 30, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    sorry modified code is this


    Code:
    #include<iostream.h>
      #include<graphics.h>
      #include<conio.h>
      #include<math.h>
      #include<stdlib.h>
      #include<stdio.h>
    
         void circlePlotPoints(int xc,int yc,int x,int y)
    
    
      int  main()
    
       {
    
          int gd=DETECT,gm;
           initgraph(&gd,&gm,"");
          clrscr();
    
          setbkcolor(WHITE);
    
        setcolor(CYAN);
        drawCircle(100,100,35);
    
       setcolor(BLUE);
       drawCircle(175,100,35);
    
       setcolor(RED);
       drawCircle(250,100,35);
    
       setcolor(YELLOW);
       drawCircle(140,150,35);
    
       setcolor(GREEN);
       drawCircle(210,150,35);
    
    
        void circlePlotPoints(int xc,int yc,int x,int y)
       {
        putpixel(xc+x,yc+y,1);
        putpixel(xc-x,yc+y,1);
        putpixel(xc+x,yc-y,1);
        putpixel(xc-x,yc-y,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc+x,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc-x,1);
        putpixel(xc+y,yc-x,1);
        }
    
    
        void drawCircle (int xc,int yc,int radius)
        {
           int x=0;
          int y=radius;
          int p=1-radius;
    
    	circlePlotPoints(xc,yc,x,y);
    
    	while(x<=y)
    	{
    	  x++;
    	  if(p<0)
    
    	    p=p+2*x+1;
    
    	  else
    	   {
    	    y--;
    	    p =p+2*(x-y)+1;
    	  }
           circlePlotPoints(xc,yc,x,y);
         }
    
       getch();
    
       }
     return 0;
        }
     
    Last edited by a moderator: Nov 30, 2011
  3. newuserme

    newuserme New Member

    Joined:
    Nov 30, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<iostream.h>
      #include<graphics.h>
      #include<conio.h>
      #include<math.h>
      #include<stdlib.h>
      #include<stdio.h>
    
    
        void circlePlotPoints(int xc,int yc,int x,int y)
    
       {
         putpixel(xc+x,yc+y,1);
        putpixel(xc-x,yc+y,1);
        putpixel(xc+x,yc-y,1);
        putpixel(xc-x,yc-y,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc+x,1);
        putpixel(xc+y,yc+x,1);
        putpixel(xc-y,yc-x,1);
        putpixel(xc+y,yc-x,1);
        }
    
    
        void drawCircle (int xc,int yc,int radius)
        {
           int x=0;
          int y=radius;
          int p=1-radius;
    
    	circlePlotPoints(xc,yc,x,y);
    
    	while(x<=y)
    	{
    	  x++;
    	  if(p<0)
    
    	    p=p+2*x+1;
    
    	  else
    	   {
    	    y--;
    	    p =p+2*(x-y)+1;
    	  }
           circlePlotPoints(xc,yc,x,y);
         }
    
    
      int  main()
    
       {// get the error here
    
          int gd=DETECT,gm;
           initgraph(&gd,&gm,"");
          clrscr();
    
          setbkcolor(WHITE);
        
        
    
        setcolor(CYAN);
        drawCircle(100,100,35);
    
       setcolor(BLUE);
       drawCircle(175,100,35);
    
       setcolor(RED);
       drawCircle(250,100,35);
    
       setcolor(YELLOW);
       drawCircle(140,150,35);
    
       setcolor(GREEN);
       drawCircle(210,150,35);
        
    
    
       getch();
    
       }
     return 0;
        }
     
    Last edited by a moderator: Nov 30, 2011

Share This Page