Thread: do while loop error

  1. #1
    Registered User
    Join Date
    Feb 2015
    Posts
    1

    do while loop error

    Hi I am a beginner and have an assignment due. I feel really stupid about saying this but i studied and did the code in c++ not c.
    While trying to redo everything in c i have an error on a do while loop and i don't understand i've corrected everything else but i don't understand why the error occurs even though it says how to fix it

    it says error expected ) before token -line 18

    part of code
    Code:
    int main(){
    
    
    
    
        Beep    (523,1000);             // sound at 523 hertz  for  1 000 milliseconds
    
    
        char cPresent;
    
    
        do
    
    
                {
                                    printf("\nPresent recieved: ");
                                    printf("Do you wish to open file (y[es] or n[o])?\n\n"); //prompt
                                    scanf ("%c"; &cPresent);
                                    printf("\n\n");
    
    
    
    
        if          (cPresent=='y' || cPresent=='Y')
    
    
                    {
    
    
                        printf("..(\ (\.\n"
                               ".(='.').\n"
                               ".((^)(^).\n");          //bunny
    
    
                        printf("I apologize in advance for my dry sense of humour\n\n");
                        system("pause");
    
    
                    }
    
    
        else if        (cPresent=='n' || cPresent=='N')
    
    
                    {
    
    
                        printf( "[ERROR] THIS IS NOT A [BRIBE]\n\n");
    
    
                    }
    
    
        else if     (cPresent!='n' ||cPresent!='y'|| cPresent<=0 ||cPresent>=0)
    
    
                    {
                        printf("[ERROR] Please enter y for yes and n for no\n\n");
    
    
                    }
    
    
                }   while (cPresent=='n'||cPresent=='N');
    }
    any help would be appreciated- this is just extra bits i've added on to the assignment but I've worked on the c++ code for a week now i have less than a day to redo it

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Look at line 18, Something shouldn't be there
    Code:
    int get_random_number(void)
    {
       return 4; //chosen by fair dice roll.
                 //guaranteed to be random
    }

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    You don't use a ; (semicolon) to separate parameters in a function call.

    Your formatting/indentation is atrocious. Please post properly formatted/indented code in the future.

    Also, please make sure you provide code with the proper header files already included so we don't have to guess.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error in loop
    By Dustin Spencer in forum C Programming
    Replies: 3
    Last Post: 09-24-2014, 05:33 PM
  2. Replies: 3
    Last Post: 08-21-2012, 11:50 PM
  3. Error In a While Loop
    By thadis_4 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2012, 04:49 PM
  4. Do While Loop Error
    By mintsmike in forum C Programming
    Replies: 4
    Last Post: 03-24-2009, 02:45 PM
  5. error in a for loop
    By saahmed in forum C Programming
    Replies: 11
    Last Post: 03-10-2006, 12:44 AM

Tags for this Thread