Advertisement
Nofxthepirate

Exercise 2.18

Jan 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. //Exercise 2.18
  2. //This program tells the user which of two numbers is larger or if they are equal
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int num1{}, num2{};
  7.  
  8. int main(){
  9.     cout << "Please enter two numbers to compare:" << endl;
  10.     cin >> num1 >> num2;
  11.     if (num1 == num2){
  12.         cout << "These numbers are equal" << endl;
  13.     }
  14.     if(num1 > num2){
  15.         cout << num1 << " is larger";
  16.     }
  17.     if (num1 < num2){
  18.         cout << num2 << " is larger";
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement