fork download
  1. //Saliha Babar CS1A Chapter 4, Page 220, #2
  2. //
  3. /************************************************************************
  4.  *
  5.  * DETERMINE THE MAXIMUM AND MINIMUM VALUE
  6.  * ______________________________________________________________________
  7.  * This program accepts two number and determines which value is larger
  8.  * and which value is smaller.
  9.  *
  10.  * There's no specific formula for this program
  11.  *________________________________________________________________________
  12.  * INPUT
  13.  * firstNum : first number entered by user
  14.  * secondNum : second number entered by user
  15.  *
  16.  * OUTPUT
  17.  * no specific output variables
  18.  * *********************************************************************/
  19. #include <iostream>
  20. using namespace std;
  21.  
  22. int main() {
  23.  
  24. int firstNum; // INPUT - first number entered by user
  25. int secondNum; // INPUT - second number entered by user
  26.  
  27. // Get user input
  28. cout << "Enter two number and I will tell\n";
  29. cout << "which number is larger and which number is smaller\n";
  30. cout << "Enter first number\n";
  31. cin >> firstNum;
  32.  
  33. cout << "Enter second number\n";
  34. cin >> secondNum;
  35.  
  36. // Determine which value is larger
  37. if ( firstNum > secondNum )
  38. cout << "The first number you entered is larger\n";
  39.  
  40. else if ( firstNum < secondNum )
  41.  
  42. cout << "The first number you entered is smaller\n";
  43.  
  44. else
  45. {
  46. cout << "Both numbers are equal\n";
  47. cout << "Run the program again with two different numbers\n";
  48. }
  49. return 0;
  50. }
Success #stdin #stdout 0s 5276KB
stdin
5
5
stdout
Enter two number and I will tell
which number is larger and which number is smaller
Enter first number
Enter second number
Both numbers are equal
Run the program again with two different numbers