Thread: I need to build a menu with a loop + scanf (without else if) and i got stuck

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2016
    Posts
    2

    I need to build a menu with a loop + scanf (without else if) and i got stuck

    Hi guys i need your help.
    I am a C beginner and i have a few problems with my project in C for my school.


    I need to build a menu: Input 1 2 3 4 5 - for other inputs print "No!"


    1 - Printf logout - Done


    2 - Doing nothing just take you back to main menu - Done


    3 - Scanf a question "Are you sure you would like to place your order"
    The user need to input "Y" or "y" and right after that the program will quit (for other input at the scanf the program will be back to main menu) - I putted the inputs "Y" 'y" in the cases but it's wrong - I don't know how to work with scanf in a loop.


    4 - I need to know how much times the program backed to main menu and write the number of "people" that used it - like if the i pressed nine times on "1" - that means that i am ten person who is using the program - i need to use "i++" some how but i don't know how to..


    5- Quit the program - my problem here is that the Default printf "No!" combined with the option i don't know how to remove the printf here


    The code-
    Code:
    #include <stdio.h>
    #include <conio.h>
    
    
    int main(void)
    {
        char ch;
    
    
        do {
            printf("\Enter number 1-5 : ");
            ch = getche();
            printf("\n");
            
    
    
            switch (ch){
    
    
            case '1':
                printf("logout\n");
                break;
    
    
            case '2':
                break;
    
    
            case '3':
                printf("Are you sure you would like to place your order ???\n");
                printf("Please enter one char: ");
                scanf("%d");
                break;
    
    
            case '4':
                printf("Your position in queue is %d\n");
                break;
    
    
            case '5':
                printf("");
    
    
            case 'y':
                printf("");
            
    
            case 'Y':
                printf("");
            
    
                /*    scanf("%c", &canceling);
    
    
    
    
        switch (canceling)
        {
        case 'Y':
        case 'y':
            printf("“Canceled");
            break;
    
    
    
    
            default:
            printf("Wrong input\n");
        }*/
                
    
            default:
                printf("No!\n"); 
                break;
        
            }
        } while (ch != '5');
        printf("");
    
    
        return 0;
    }
    Last edited by hitnoob; 12-01-2016 at 06:46 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stuck on scanf ?????
    By zmhnak in forum C Programming
    Replies: 4
    Last Post: 03-23-2013, 07:37 AM
  2. stuck with scanf %s
    By pipskie in forum C Programming
    Replies: 6
    Last Post: 01-21-2013, 09:02 AM
  3. How to build a flexible Game Menu..
    By ThLstN in forum Game Programming
    Replies: 1
    Last Post: 12-13-2008, 10:53 AM
  4. Help.. newbie for loop..stuck with the loop..
    By jochen in forum C Programming
    Replies: 15
    Last Post: 10-01-2007, 12:31 AM
  5. for loop ignoring scanf inside loop
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-17-2007, 01:46 AM

Tags for this Thread