Thread: eof error in program

  1. #1
    Registered User jamez's Avatar
    Join Date
    Nov 2005
    Posts
    10

    eof error in program

    Can someone tell me what i'm missing. i think i've been looking at this code too long, and i've had too many variations of it to see it myself. any help is greatly appreciated.

    Code:
    #include <stdio.h>
    
    int main(void) 
    {
     int firstclass[3] = {0};
     int coachclass[5] = {0};
     int code = 0;
     int i = 0;
     int fccount = 0;
     int cccount = 0;
    
      while (code != 99)
       {
        if (fccount < 3)
         {
          printf( "Press [1] for First Class\n" );
         }
        else
         {
          printf( "First Class not available\n" );
         {
        if (cccount < 5)
         {
        printf( "Press [2] for Coach Class\n" );
         }
        else
         {
        printf( "Coach Class not available.\n" );
         }
        if ((fccount > 3) && (cccount > 5))
         {
           break;
         }
    
      scanf( "%d", &code );
       if (code == 1)
        {
         firstclass[fccount] = 1;
         fccount = fccount + 1;
         code = 0;
        }
       else if ( code == 2 )
        {
         coachclass[cccount] = 1;
         cccount = cccount +1;
         code = 0;
        }
       else if ( code == 99 )
        {
         printf( "You have entered << 99 >> this program has ended\n" );
        }
       else
        {
         printf( "Invalid code - please try again\n\n" );
         code = 0;
        }
      }
     return 0;
    }

  2. #2
    Bond sunnypalsingh's Avatar
    Join Date
    Oct 2005
    Posts
    162
    Here's The Corrected Code....1st else had a wrong closing brace....
    Code:
    #include <stdio.h>
    
    int main(void) 
    {
     int firstclass[3] = {0};
     int coachclass[5] = {0};
     int code = 0;
     int i = 0;
     int fccount = 0;
     int cccount = 0;
    
      while (code != 99)
       {
        if (fccount < 3)
         {
          printf( "Press [1] for First Class\n" );
         }
        else
         {
          printf( "First Class not available\n" );
    	}//problem was here
        if (cccount < 5)
         {
        printf( "Press [2] for Coach Class\n" );
         }
        else
         {
        printf( "Coach Class not available.\n" );
         }
        if ((fccount > 3) && (cccount > 5))
         {
           break;
         }
    
      scanf( "%d", &code );
       if (code == 1)
        {
         firstclass[fccount] = 1;
         fccount = fccount + 1;
         code = 0;
        }
       else if ( code == 2 )
        {
         coachclass[cccount] = 1;
         cccount = cccount +1;
         code = 0;
        }
       else if ( code == 99 )
        {
         printf( "You have entered << 99 >> this program has ended\n" );
        }
       else
        {
         printf( "Invalid code - please try again\n\n" );
         code = 0;
        }
      }
     return 0;
    	 }

  3. #3
    Registered User jamez's Avatar
    Join Date
    Nov 2005
    Posts
    10
    Thanks for the help. I guess my vision was pretty screwy after looking at that code for so long, I knew it was something dumb like that that i was missing. Thanks a million.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM