fork download
  1. // Marvyn De La Torre CS1A Chapter 4, P.220, #1
  2.  
  3. /**************************************************************
  4. * Determine Minimum and Maximum
  5. *
  6. * This program determines the smaller and larger of two numbers.
  7. *
  8. * Input:
  9. * Number 1 = num1
  10. * Number 2 = num2
  11. *
  12. * Output:
  13. * Smaller number = smaller
  14. * Larger number = larger
  15. **************************************************************/
  16.  
  17. #include <iostream>
  18. using namespace std;
  19.  
  20. int main()
  21. {
  22. double num1, num2;
  23. double smaller, larger;
  24.  
  25. cout << "Enter the first number: ";
  26. cin >> num1;
  27.  
  28. cout << "Enter the second number: ";
  29. cin >> num2;
  30.  
  31. smaller = (num1 < num2) ? num1 : num2;
  32. larger = (num1 > num2) ? num1 : num2;
  33.  
  34. cout << "Smaller: " << smaller << endl;
  35. cout << "Larger: " << larger << endl;
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5328KB
stdin
10.5 42
stdout
Enter the first number: Enter the second number: Smaller: 10.5
Larger: 42