Thread: need to loop my prog. after the prompt

  1. #1

    Lightbulb need to loop my prog. after the prompt

    //snippet of what my prog looks like
    printf("please enter the amount of questions evaluated ")

    printf("the amount student got correct")

    div(num2,num2)* 100// this is basically
    //how its set up.
    //here's where the problem lies..
    char yn;
    printf("would you like to convet any other
    test scores\n");
    printf(" press 'y' and enter to continue
    press 'n' plus enter to exit program");
    //i need to loop the program if the user
    //selects 'y'. i have tried the book samples but oviously i'm understanding
    //the book wrong. desperate now!
    please help!!!!!

  2. #2
    Follow the link in my sig. Under the Information heading, follow "An introduction to simple C++ functions". Look up 'getch' and the 'for' and 'do...while' loop examples.
    "There's always another way"
    -lightatdawn (

  3. #3
    Registered User
    Join Date
    Aug 2002
    Hermosa Beach, CA
    do {

    // your code here

    } while ( user_response != 'y' && user_response != 'Y' );

    Just be sure that any variables are reinitialized when you go back to the top of the loop. One way to do this is:

    do {


    // now prompt

    } while( user_response != 'y' && user_response != 'Y' );

    By making your code a separate function, you guarantee that the data is reinitialized every time.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My loop within loop won't work
    By Ayreon in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 10:44 AM
  2. Visual Studio Express / Windows SDK?
    By cyberfish in forum C++ Programming
    Replies: 23
    Last Post: 01-22-2009, 02:13 AM
  3. Replies: 8
    Last Post: 12-01-2008, 10:09 AM
  4. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-31-2006, 12:59 AM
  5. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM