help me. undefine symbol in function main.

This is a discussion on help me. undefine symbol in function main. within the C Programming forums, part of the General Programming Boards category; Code: #include<stdio.h> #include<conio.h> char *str,select; main() { int item; do { clrscr(); printf("1. FACTORIAL\n"); printf("2. FIBONACCI\n"); printf("3. EUCLID\n"); printf("4. EXIT\n"); ...

  1. #1
    Registered User Melody's Avatar
    Join Date
    Nov 2007
    Location
    Philippines
    Posts
    57

    Question help me. undefine symbol in function main.

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    char *str,select;
    
    main()
    {
    int item;
          do
          {
    		clrscr();
    		printf("1. FACTORIAL\n");
    		printf("2. FIBONACCI\n");
    		printf("3. EUCLID\n");
    		printf("4. EXIT\n");
    		printf("SELECT AN OPTION:\n");
    		scanf("%d",&item);
    		if (item==1)
    		{
    			clrscr();
    {
    long a,b,c;
    gotoxy(1,1);
    printf("RECURSIVE\n");
    printf("Enter a Number: ");
    scanf("%li",&a);
    c=1;
    b=1;
    do
    {
    printf("%li = %li*%li=%li\n",b,b,c,b*c);
    c*=b;
    b++;
    }while(b<=a);
    printf("FACTORIAL IS %li",c);
    }
    getch();
    }
    
    else if (item==2)
    		{	clrscr();
    {
    int f,a,b,c,ctr;
    gotoxy(1,1);
    printf("ITERATION\n");
    printf("ENTER A NUMBER: ");
    scanf("%d",&c);
    f=1;
    a=1;
    if(c<1)
    printf("TRY AGAIN");
    else
    printf("0\t");
    for(ctr=1;ctr<=c;ctr++)
    {
    printf("%d\t",f)
    if(ctr>1)
    {
    b=f+a;
    a=f;
    f=b;
    }
    }
    getch();
    }
    }
    
    		else if (item==3)
    
    		{
    		clrscr();
    		long a,b,q,r;
    		gotoxy(1,1);
    		do
    		{
    		printf("ENTER IST  NUMBER :");
    		scanf("%li",&a);
    		printf("ENTER 2ND NUMBER :");
    		scanf("li",&b);
    		}
    		while(b>a);
    		do
    		{
    		q=a/b;
    		r=a%b;
    		printf("%li=%li(%li)+li \n",a,b,q,r);
    		a=b;
    		b=r;
    		}
    		while(r>0);
    		printf("GCD is %li",a);
    		getch()
    		}}
    			else if (item==4)
    			{
    			break;
    			}
    			else
    			{
    				printf("Invalid Input! Press Any Key to Continue...");
    				getch();
    			}
    		}while(item!="2");
    		getch();
    		}

    help me. guys. i have 10 errors..

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    You going to post the errors, or do you expect us to find them and fix them ourselves?

    Incidentally, this is horrible code. It's written to use all the ye olde conio.h stuff, and the indentation doesn't even exist at some points in the code.

  3. #3
    Registered User Melody's Avatar
    Join Date
    Nov 2007
    Location
    Philippines
    Posts
    57
    Code:
    #include<stdio.h>
    #include<conio.h>
    
    char *str,select;
    
    main()
    {
    int item;
          do
          {
    		clrscr();
    		printf("1. FACTORIAL\n");
    		printf("2. FIBONACCI\n");
    		printf("3. EUCLID\n");
    		printf("4. EXIT\n");
    		printf("SELECT AN OPTION:\n");
    		scanf("&#37;d",&item);
    		if (item==1)
    		{
    			clrscr();
    {
    long a,b,c;
    gotoxy(1,1);
    printf("RECURSIVE\n");
    printf("Enter a Number: ");
    scanf("%li",&a);
    c=1;
    b=1;
    do
    {
    printf("%li = %li*%li=%li\n",b,b,c,b*c);
    c*=b;
    b++;
    }while(b<=a);
    printf("FACTORIAL IS %li",c);
    }
    getch();
    }
    
    else if (item==2)
    		{	clrscr();
    {
    int f,a,b,c,ctr;
    gotoxy(1,1);
    printf("ITERATION\n");
    printf("ENTER A NUMBER: ");
    scanf("%d",&c);
    f=1;
    a=1;
    if(c<1)
    printf("TRY AGAIN");
    else
    printf("0\t");
    for(ctr=1;ctr<=c;ctr++)
    {
    printf("%d\t",f);
    if(ctr>1)
    {
    b=f+a;
    a=f;
    f=b;
    }
    }
    getch();
    }
    }
    
    		else if (item==3)
    
    		clrscr();
    		{
    		long a,b,q,r;
    		gotoxy(1,1);
    		do
    		{
    		printf("ENTER IST  NUMBER :");
    		scanf("%li",&a);
    		printf("ENTER 2ND NUMBER :");
    		scanf("li",&b);
    		}
    		while(b>a);
    		do
    		{
    		q=a/b;
    		r=a%b;
    		printf("%li=%li(%li)+li \n",a,b,q,r);
    		a=b;
    		b=r;
    		}
    		while(r>0);
    		printf("GCD is %li",a);
    		getch();
    		}
    		}
    			else if (item==4)
    			{
    			break;
    			}
    			else
    			{
    				printf("Invalid Input! Press Any Key to Continue...");
    				getch();
    			}
    		}while(item!="2");
    		getch();
    		}
    i have 3 errors.
    the errors are.

    95: do statement must have while in function main.
    104: declaration syntax error
    106: declaration syntax error.


    help me please.

  4. #4
    Registered User Melody's Avatar
    Join Date
    Nov 2007
    Location
    Philippines
    Posts
    57
    MY errors are.
    95: do statement must have while in function main.
    104: declaration syntax error
    106: declaration syntax error.
    help me please.

  5. #5
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    Your answers are in your other thread.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Fix your indenting first, otherwise I'm not gonna bother looking at it. I don't need any more headaches. But once you indent properly, I suspect the problem will be much more evident.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. VC++ a POS
    By Welder in forum Windows Programming
    Replies: 40
    Last Post: 11-07-2007, 02:07 PM
  3. wxWidgets link problem
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2006, 01:36 PM
  4. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 03:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21