fork download
  1. //Matthew Santos CS1A Ch. 4, Pg. 220, #1
  2. /***********************************************
  3.  *
  4.  * DETERMINE LARGER/SMALLER NUMBER
  5.  * _____________________________________________
  6.  * Determines which number of the two ais bigger
  7.  * and smaller.
  8.  * _____________________________________________
  9.  * INPUT
  10.  * num1 : first number inputted
  11.  * num2 : second number inputted
  12.  *
  13.  * OUTPUT
  14.  * Displays greater and lesser number
  15.  ***********************************************/
  16. #include <iostream>
  17. #include <iomanip>
  18. using namespace std;
  19.  
  20. int main() {
  21.  
  22. //Initialize inputs
  23. float num1;
  24. float num2;
  25.  
  26. //Ask for numbers
  27. cout << "Enter two different numbers:" << endl;
  28. cin >> num1;
  29. cin >> num2;
  30.  
  31. //Determine greater number
  32. if (num1 > num2)
  33. {
  34. cout << num1 << " is greater than " << num2 << endl;
  35. }
  36. else
  37. {
  38. if (num1 < num2)
  39. cout << num2 << " is greater than " << num1 << endl;
  40. }
  41.  
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter two different numbers:
36 is greater than 35