How to return to main screen?

This is a discussion on How to return to main screen? within the C Programming forums, part of the General Programming Boards category; Hello! I managed to run a program like this: Recipe List 1) Meat Balls 2) Curry 3) Steak 4) Vegetable ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    7

    How to return to main screen?

    Hello!

    I managed to run a program like this:

    Recipe List

    1) Meat Balls
    2) Curry
    3) Steak
    4) Vegetable Stew

    Choice:_
    If the user input 1, this will happen:

    Meat Balls

    Ingredients:
    blah..
    blah..


    Would you like to check another recipe? Y/N _
    Now, the question is: If the user input 'Y', how will I return to my program's "home page" which is

    Recipe List

    1) Meat Balls
    2) Curry
    3) Steak
    4) Vegetable Stew

    Choice:_
    Thanks for the help!
    ----------------------------------------------------------------

    My next question would be:

    What's a good program (looping statement) for this one:

    1
    4
    9
    16
    25

    Thanks for the replies!
    Last edited by clie00; 09-23-2007 at 11:15 PM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,959
    You might use an algorithm like:
    Code:
    check_recipe_flag = true
    while check_recipe_flag
        print menu
        read user's option
        display recipe
        check_recipe_flag = check_next_recipe()
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    Okay, I'll try that. Thanks, I am just a freshie student. T__T

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    Oops, I didn't work on mine. ;_;

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,959
    What do you mean?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    There are errors, I'll try to remake it later.

  7. #7
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by clie00 View Post
    There are errors
    your detailed problem description is applaudable
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  8. #8
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    I wrote my program this way:

    Code:
    #include<conio.h>
    #include<stdio.h>
    void main()
    {
    clrscr();
    int choice;
    printf("Recipe List\n");
    printf("1) Meat Balls\n");
    printf("2) Curry\n");
    printf("3) Steak\n");
    printf("4) Vegetable Stew\n\n");
    printf("Enter No. of Choice:");
    scanf("&#37;d",&choice")
         if (choice==1)
           {
            clrscr();
            int wouldyoulike
            printf("Meatballs Ingredients\n");
            printf("Would you like to see our other recipes? (1) Yes (2) No");
            scanf("%d",&wouldyoulike);
    Okay, so let's stop here. The monitor yould output this like:

    Code:
    Recipe List
    
    1) Meat Balls
    2) Curry
    3) Steak
    4) Vegetable Stew
    
    Choice:_
    If the user input 1, this will happen:

    Code:
    Meat Balls Ingredients:
    
    
    Would you like to see our other recipes? (1) Yes (2) No _
    Now, the question is: If the user input '1', how will I return to my program's "home page" which is

    Code:
    Recipe List
    
    1) Meat Balls
    2) Curry
    3) Steak
    4) Vegetable Stew
    
    Choice:_
    Last edited by Salem; 09-24-2007 at 09:30 AM. Reason: Please use CODE tags for anything which needs formatting preserved.

  9. #9
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by clie00 View Post
    ... I don't know what's next here. ;_:
    How about indentation and posting the compiler errors you get?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  10. #10
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    I edited my post Quantum, I'll tell the errors later, forgive I am not home tonight (here in our country)
    Last edited by clie00; 09-24-2007 at 07:21 AM.

  11. #11
    Registered User
    Join Date
    Sep 2007
    Posts
    7
    Where will I put this one?
    check_recipe_flag = true
    while check_recipe_flag
    print menu
    read user's option
    display recipe
    check_recipe_flag = check_next_recipe()

  12. #12
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by clie00 View Post
    Where will I put this one?
    That's pseudocode. You turn it into actual code yourself. Read through it to understand what kind of workflow your program should have and then try to code that.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 09-23-2008, 07:27 PM
  2. Render text
    By Livijn in forum C++ Programming
    Replies: 6
    Last Post: 07-06-2007, 03:32 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09:18 PM
  5. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM

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