Thread: no accepting my loop

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    3

    no accepting my loop

    /I am writting a menu program that lets the user select from a list of options, and if the input is not one
    /of the options, reprint the list.

    /Its not accepting my loop

    Code:
     #include <iostream>
    using namespace std;
    int main ()
    {
    int a, b, c, x1, x2 ;
    cout << "Please select from the following a, b, c \n";
    cin >> x1;
    
    while ( ! x2 == a || ! x2 == b || ! x2 == c );
    {
    cout << "Please select again \n" ;
    cin >> x2;
       }
         cin.get ();
    }
    Last edited by Reggie Green; 10-14-2012 at 07:10 PM.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    You may mean something like this:
    Code:
    #include <iostream>
    using namespace std;
    
    int main () {
        char x;
        cout << "Please select from the following a, b, c \n";
        cin >> x;
        while ( ! (x == 'a' || x == 'b' || x == 'c') )
        {
            cout << "Please select again \n" ;
            cin >> x;
        }
        cin.get ();
        return 0;
    }
    You need to read your book more because you seem to have many misunderstandings.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    3
    Thank you for help. I am trying I have been studying so eventually I will get it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. accepting two inputs
    By Aratel in forum C++ Programming
    Replies: 11
    Last Post: 10-09-2012, 07:14 PM
  2. getchar() not accepting 'ans' value
    By Zaheer Attar in forum C Programming
    Replies: 4
    Last Post: 09-10-2011, 01:42 PM
  3. accepting +123 help
    By peanut in forum C Programming
    Replies: 7
    Last Post: 11-01-2006, 10:48 PM
  4. Accepting function key 'F12'
    By Fire Flash in forum C Programming
    Replies: 1
    Last Post: 03-18-2002, 03:32 PM
  5. accepting char and int
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-02-2001, 10:48 PM