fork download
  1. // Mariah Contreras CSC5 Chapter 4, P.222, #1
  2. //
  3. /* ************************************************************
  4.  *
  5.  * COMPARE NUMBER VALUES
  6.  * ____________________________________________________________
  7.  * This program prompts the user to enter two numbers. Then
  8.  * compares the numbers.
  9.  * ____________________________________________________________
  10.  * INPUT
  11.  * num1 : First number
  12.  * num2 : Second number
  13.  * OUTPUT
  14.  *
  15.  **************************************************************/
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main ()
  20. {
  21. float num1, //INPUT - First number entered.
  22. num2; //INPUT - Second number entered.
  23. //
  24. //Ask the user enter two numbers
  25. cout << "Enter the first number";
  26. cin >> num1;
  27. cout << "\nEnter the second number";
  28. cin >> num2;
  29. //
  30. //Compare number values
  31. if (num1 > num2)
  32. cout << endl << num1 << " is greater than " << num2;
  33. else if (num2 > num1)
  34. cout << endl << num2 << " is greater than " << num1;
  35. else
  36. cout << endl << num1 << " is equal to " << num2;
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5548KB
stdin
1 
1
stdout
Enter the first number
Enter the second number
1 is equal to 1