fork download
  1. //Jacob Silvestre CSC5 Chapter 4, P. 220, #1
  2. //
  3. /************************************************************************************
  4. *
  5. * DETERMINE MAX AND MIN
  6. *____________________________________________________________________________________
  7. * This program takes the input of two numbers and labels which number is smaller and
  8. * which is larger.
  9. *____________________________________________________________________________________
  10. * INPUT
  11. * num1 : First number
  12. * num2 : Second number
  13. *
  14. * OUTPUT
  15. * smaller : Smaller number
  16. * larger : Larger number
  17. *
  18. **************************************************************************************/
  19.  
  20. #include <iostream>
  21. using namespace std;
  22.  
  23. int main()
  24. {
  25. double num1; // INPUT - First number
  26. double num2; // INPUT - Second number
  27. double smaller; // OUTPUT - Smaller number
  28. double larger; // OUTPUT - Larger number
  29.  
  30. //
  31. // Get Two Numbers
  32. //
  33. cout << "Enter the first number: ";
  34. cin >> num1;
  35.  
  36. cout << "Enter the second number: ";
  37. cin >> num2;
  38.  
  39. //
  40. // Find the Smaller and Larger Number
  41. //
  42. smaller = (num1 < num2) ? num1 : num2;
  43. larger = (num1 > num2) ? num1 : num2;
  44.  
  45. //
  46. // Display Results
  47. //
  48. cout << "Smaller number: " << smaller << endl;
  49. cout << "Larger number: " << larger << endl;
  50.  
  51. return 0;
  52. }
  53.  
  54.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Enter the first number: Enter the second number: Smaller number: 4.65469e-310
Larger number: 6.95273e-310