Thread: do while loops

  1. #1
    Registered User
    Join Date
    Dec 2001

    do while loops

    Hiya - I'm getting very confused with do-while loops, I'm trying to do a more complicated version of this but I know that if I get the hang of this I can do my propler program!

    The problem is that no matter what number I initially enter it tells me that it is an odd number but then works after that!

    Can anyone explain what I'm doing wrong please - I'm going crazy!

    //using namespace std;
    int main()
    int value;
    cout << "enter even number" << endl;
    cin >> value;

    while (value%2==1) // if odd

    cout << "that is an odd number try again";
    cin >> value;

    cout << endl << "that is correct"; // if even

    return 0;

  2. #2
    Registered User
    Join Date
    Nov 2001
    it is do while not while do... change your location of the while

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple thread for loops
    By lehe in forum C++ Programming
    Replies: 12
    Last Post: 03-29-2009, 12:01 PM
  2. Too many loops D:
    By F5 Tornado in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2007, 01:18 AM
  3. recoursion or loops?
    By Mecnels in forum C++ Programming
    Replies: 2
    Last Post: 01-14-2002, 12:09 PM
  4. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM
  5. for loops - newbie q's
    By Narciss in forum C Programming
    Replies: 8
    Last Post: 09-26-2001, 02:44 AM