Advertisement
ivanwidyan

Compares Two Ages Who's Older, New Behavior If Both > 100

Oct 16th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int firstage, secondage;
  6.  
  7.     cout << "Enter your first age: ";
  8.     cin >> firstage;
  9.     cout << "Enter your second age: ";
  10.     cin >> secondage;
  11.  
  12.     if (firstage > secondage) {
  13.         cout << firstage << " > " << secondage << endl;
  14.     }
  15.     else if (secondage > firstage) {
  16.         cout << secondage << " > " << firstage << endl;
  17.     }
  18.     else if (firstage > 100 && secondage > 100) {
  19.         cout << firstage << " and " << secondage << " are both over 100"<< endl;
  20.     }
  21.     else {
  22.         cout << firstage << " = " << secondage << endl;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement