Thread: Why won't my loop work?

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    11

    Why won't my loop work?

    Code:
    int main()
    {
        int userOne;
        int userTwo;
        int userThree;
        int userFour;
        int userFive;
        int max;
        int min;
        int average;
        int userAnswer;
        do 
        {
        cout<< "Enter in 5 numbers (minimum value 1, maximum value 100)" <<endl;
        cin>> userOne;
        if ((userOne <1) || (userOne >100 ))
        {
            cout<< "Error, Enter in a number minimum value of 1, maximum value of 100" <<endl;
            cin>> userOne;
        }
        cin>> userTwo;
        if ((userTwo <1) || (userTwo >100 ))
        {
            cout<< "Error, Enter in a number minimum value of 1, maximum value of 100" <<endl;
            cin>> userTwo;
        }
        cin>> userThree;
        if ((userThree <1) || (userThree >100 ))
        {
            cout<< "Error, Enter in a number minimum value of 1, maximum value of 100" <<endl;
            cin>> userThree;
        cin>> userFour;
        }
        if ((userFour <1) || (userFour >100 ))
        {
            cout<< "Error, Enter in a number minimum value of 1, maximum value of 100" <<endl;
            cin>> userFour;
        cin>> userFive;
        }
        if ((userFive <1) || (userFive >100 ))
        {
            cout<< "Error, Enter in a number minimum value of 1, maximum value of 100" <<endl;
            cin>> userFive;
        }
        display (userOne, userTwo, userThree, userFour, userFive);
     // isPrime (userOne, userTwo, userThree, userFour, userFive);
        max = maxValue (userOne, userTwo, userThree, userFour, userFive);
        cout<< "Max value is: " << max <<endl;
        min = minValue (userOne, userTwo, userThree, userFour, userFive);
        cout<< "Min value is: " << min <<endl;
        average = averageValue (userOne, userTwo, userThree, userFour, userFive);
        cout<< "Average (as a double) is: " << average <<endl;
        zeroValues (userOne, userTwo, userThree, userFour, userFive);
        cout<< "All values have been reset" <<endl;
        cout<< userOne <<endl;
        cout<< userTwo <<endl;
        cout<< userThree <<endl;
        cout<< userFour <<endl;
        cout<< userFive <<endl;
        cout<< "Do you want to run this program again? (Press 'Y' to run again)" <<endl;
        cin >> userAnswer;
        }
        while (userAnswer == 'Y'); //|| (userAnswer == 'y'));
        return 0;
    }
    When I input Y, my program won't loop. I can't see what's wrong with it. ;(

  2. #2
    Registered User
    Join Date
    Feb 2014
    Posts
    11
    FIXED!
    turns out I used int instead of char.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why will my loop does not work
    By atoivan in forum C Programming
    Replies: 2
    Last Post: 11-10-2011, 11:21 AM
  2. Can't get the loop to work
    By pass_prime in forum C Programming
    Replies: 10
    Last Post: 06-20-2005, 03:46 PM
  3. My loop doesnt work
    By Evandb in forum C Programming
    Replies: 3
    Last Post: 05-17-2004, 11:04 PM
  4. why does this loop work, but the other doesn't?
    By Shadow12345 in forum C++ Programming
    Replies: 5
    Last Post: 12-10-2002, 07:07 PM
  5. cant get the loop to work right
    By djxtremor in forum C Programming
    Replies: 3
    Last Post: 10-30-2002, 06:34 AM