fork download
  1. //Andres Guzman CSC5 Chapter 4, P. 220, #1
  2. //
  3. /**************************************************************
  4. *
  5. * DETERMINE THE LARGER NUMBER
  6. * ____________________________________________________________
  7. * This program will display the larger and smaller number between two inputs
  8. *
  9. * Computation is based on the formula:
  10. * num = num1 < num2
  11. * ____________________________________________________________
  12. * INPUT
  13. * num1 = the first number inputed
  14. * num2 = the second number inputed
  15. * OUTPUT
  16. * num = the larger and/or smaller number
  17. *
  18. **************************************************************/
  19. #include <iostream>
  20. #include <iomanip>
  21. #include <string>
  22. using namespace std;
  23.  
  24. int main ()
  25. {
  26. double num1, num2; //Numbers for the programmer to input
  27. string num; //The scaling of the numbers inputed
  28. //
  29. //
  30. cout << "Enter Two numbers.";
  31. cout << "\nNumber 1: ";
  32. cin >> num1;
  33. cout << "\nNumber 2: ";
  34. cin >> num2;
  35. //
  36. //
  37. cout << (num = num1 < num2 ? num1: num2); //Determines the larger number
  38. cout << " is the larger number while ";
  39. cout << (num = num1 < num2 ? num2: num1); //Determines the smaller number
  40. cout << " is the smaller number.";
  41. }
  42.  
Success #stdin #stdout 0s 5312KB
stdin
12 10
stdout
Enter Two numbers.
Number 1: 
Number 2: 
 is the larger number while  is the smaller number.