fork download
  1. //Cecilia Rangel CSC5 Chapter 4, P. 220, #1
  2. //
  3. /**************************************************************
  4.  *
  5.  * COMPUTE NUMBER VALUES
  6.  * ____________________________________________________________
  7.  * This program computes which number is the smaller or bigger
  8.  * out of two numbers prompted by the user
  9.  *
  10.  * This program will utilize the following relational operators:
  11.  * >(greater than), <(less than), and ==(equal to)
  12.  *___________________________________________________________
  13.  * INPUT
  14.  * num1 : first user input
  15.  * num2 : second user input
  16.  *
  17.  * OUTPUT
  18.  * display : which number is greater
  19.  *
  20.  **************************************************************/
  21. #include <iostream>
  22. #include <iomanip>
  23. using namespace std;
  24.  
  25. int main() {
  26. float num1; //INPUT - first number
  27. float num2; //INPUT - second number
  28.  
  29. cout << "Enter the first number\n";
  30. cin >> num1;
  31. cout << "Enter the second number\n";
  32. cin >> num2;
  33.  
  34. if (num1 > num2)
  35. {
  36. cout << num1 << " is the larger number\n";
  37. cout << num2 << " is the smaller number\n";
  38. }
  39. if (num1 < num2)
  40. {
  41. cout << num1 << " is the smaller number\n";
  42. cout << num2 << " is the larger number\n";
  43. }
  44. if (num1 == num2)
  45. cout << "Both numbers are equal to each other\n";
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 5312KB
stdin
30
55
stdout
Enter the first number
Enter the second number
30 is the smaller number
55 is the larger number