Thread: Confusion using the DO-WHILE LOOP in C,to assign a control.. Refer to my source code.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    10

    Confusion using the DO-WHILE LOOP in C,to assign a control.. Refer to my source code.

    I'm writing a small program which asks a user to input 6 numbers.

    It then displays it on the screen..

    (*)Then, it asks the user again if he wants to input any more numbers..

    If the user enters 'y'..he can input another 6 numbers..this goes on and on until he enters 'n' for the question in (*) and the program will end..

    below is the code

    Code:
    int u_num[6];
        char answer;
        int count=0;
    
      do
          
          {   
             printf("Please input any six numbers (from 1 to 40) \n");
        
             for (i=0; i<6; i++)
                 {
                       scanf("%d", &u_num[i]);
                 }
           
             printf(" Your Numbers are:");
                    
             for (i=0; i<6; i++)
                 {
                       printf(" --%d--", u_num[i]);
                 }
                 
                
               
           
                 printf("\n\n Do you want to input any more number? \n\n");
                 scanf("%c", &answer);
           }
               while(answer!='n');
    }
    The problem that is occurring is that I'm getting the message

    "Please insert your 6 numbers" along with
    "Do you want to input any more??"

    [Refer to attachment]

    I just want this "Do you want to input any more??" to be displayed..

    Any help or suggestion???
    Attached Images Attached Images Confusion using the DO-WHILE LOOP in C,to assign a control.. Refer to my source code.-attachement-jpg 

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  2. Simple code: Can 2 references refer to the same object?
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 05-14-2008, 08:27 PM
  3. Replies: 4
    Last Post: 01-18-2008, 07:05 PM
  4. Source Code Control Systems
    By Isometric in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-06-2002, 04:46 AM

Tags for this Thread