evetsleep

Testing with 10

Oct 25th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     //Initialize the two integers that we'll be testing against.
  8.     int firstNumber;
  9.     int secondNumber;
  10.  
  11.     //Prompt for the first integer to accept and store.
  12.     cout << "Please enter the first number: ";
  13.     cin >> firstNumber;
  14.  
  15.     //Prompt for the second integer to accept and store.
  16.     cout << "Please enter the second number: ";
  17.     cin >> secondNumber;
  18.  
  19.     //Test to see if both numbers are greater than 10.
  20.     //If they are we print that to screen and then stop.
  21.     if ( firstNumber > 10 && secondNumber > 10)
  22.         cout << "The numbers" << firstNumber << " and " << secondNumber << " are both over 10";
  23.    
  24.     //If both numbers are not greater than 10 we test to
  25.     //see if they are less than 10.  If they are we out put that.
  26.     else if (firstNumber <= 10 && secondNumber <= 10)
  27.         cout << "The numbers " << firstNumber << " and " << secondNumber << " are both under 10";
  28.    
  29.     //We check to see if both numbers are equal to 10 exactly.  If is we send that
  30.     //to screen.
  31.     else if (firstNumber == 10 && secondNumber == 10)
  32.         cout << "Both numbers are equal to 10!.";
  33.     //If nothing matches we send out what their relation is to the number 10.
  34.     else
  35.     {
  36.         if (firstNumber > 10)
  37.             cout << "The first number,  " << firstNumber << " is above 10.\n";
  38.         else if (firstNumber < 10)
  39.             cout << "The first number, " << firstNumber << " is below 10.\n";
  40.         if (secondNumber > 10)
  41.             cout << "The second  number, " << secondNumber << " is above 10.\n";
  42.         else if (secondNumber < 10)
  43.             cout << "The second number, " << secondNumber << " is below 10.\n";
  44.     }
  45.  
  46.     //Return the exit code of 0.
  47.     return 0;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment