fork download
  1. // Castulo Jason Quintero CSC5 Chapter 4, P. 220, #1
  2. //
  3. /*******************************************************************************
  4. *
  5. * Determine Minium and Maximum of Two Numbers
  6. * ______________________________________________________________________________
  7. * This program collects user input of two numbers and will determine
  8. * which number is larger and which is smaller
  9. *
  10. * ______________________________________________________________________________
  11. * INPUT
  12. * numOne : Users first number
  13. * numTwo : Users second number
  14. *
  15. * OUTPUT
  16. * larger than : numOne > numTwo
  17. * smaller than : numOne < numTwo
  18. *
  19. *******************************************************************************/
  20. #include <iostream>
  21. #include <iomanip>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26.  
  27. //DECLARE VARIABLES
  28. float numOne;
  29. float numTwo;
  30.  
  31. //INPUT TWO NUMBERS
  32.  
  33. cout << "Input a number\n";
  34. cin >> numOne ;
  35.  
  36. cout << "Input another number\n";
  37. cin >> numTwo;
  38.  
  39. //INPUT VALIDATION - DETERMINE WHICH IS SMALLER AND WHICH IS LARGER
  40. if (numOne > numTwo)
  41. {
  42. cout << numOne << " is larger than "; //OUTPUT - LARGE
  43. cout << numTwo;
  44. }
  45.  
  46. else if (numOne < numTwo)
  47. {
  48. cout << numOne << " is smaller than "; //OUTPUT - SMALL
  49. cout << numTwo;
  50. }
  51.  
  52. else if (numOne == numTwo)
  53. { cout << numOne << " is equal to "; //OUTPUT - EQUAL
  54. cout << numTwo;
  55. }
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 5300KB
stdin
20
10
stdout
Input a number
Input another number
20 is larger than 10