Question

Create a code in C++ that ask the user for 2 values and checks (and informs...

Create a code in C++ that ask the user for 2 values and checks (and informs the user) if they are less than, greater than or equal to each other.

Homework Answers

Answer #1

C++ code pasted below.

#include <iostream>
using namespace std;
int main()
{ float a,b;
cout<<"Enter 2 numbers:";
cin>>a>>b;
if(a>b)
cout<<"First number "<<a<<" is greater than second number "<<b;
else if(a<b)
cout<<"First number "<<a<<" is less than second number "<<b;
else
cout<<"First number "<<a<<" is equal to the second number "<<b;
return 0;
}

Output Screen - Test case 1

Output Screen - Test case 2

Output Screen - Test case 3

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Classwork_1.5: Write a C code that ask the user to enter the name of person, gender...
Classwork_1.5: Write a C code that ask the user to enter the name of person, gender (male or female) and age and display these quantities. You need to create a structure to solve this problem. Output:
Create a program that checks for normal body temperature. The program will ask the patient to...
Create a program that checks for normal body temperature. The program will ask the patient to provide their temperature in Fahrenheit. The normal body temperature ranges from 97 to 99℉. Inform the user that their temperature is normal or ask them to see a doctor depending on the results. Which variation of the if statement would best fit the requirements (if, if-else, if-else-if chain, nested if)? You don't need to create the entire program. You only need to create the...
Write a while loop to ask the user to type number of hours(double) they work per...
Write a while loop to ask the user to type number of hours(double) they work per day. Calculate and print the salary for each valid input. If number of hours is greater than or equal to 0 and less than 5, then:  salary = numberofhours * 5, loop continues, the user can type another number If number of hours is greater or equal to 5, and less than 10, then: salary = numberofours * 8, loop continues, the user can type...
Create a program to ask the user for an integer number, positive only. If the number...
Create a program to ask the user for an integer number, positive only. If the number is between 0 and 255, printout the number in binary format to the screen. This will involve checking the bits, one by one, starting from the most significant place: 128. Use c++ 1. Modify the program to find the binary number, using a FOR loop, instead of the manual checking of each bit separately 2. What are the bitwise XOR and INVERSION operators? Find...
Write a program that checks the age of a user (C++ Programming)    If the user...
Write a program that checks the age of a user (C++ Programming)    If the user is 18 to 20 print “Sing a song” If the user is younger than 18 then print “Please show a dance step” Else Welcome the user and print “You are audience”
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for...
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for 5 bases and 5 heights (you can use an array), have a function to print the triangle bases, heights, and areas 2. Create a structure for the Triangle that holds the base and height of the triangles. Ask the user for 5 triangles, and print them. 3. Create an array of 5 structures - ask the user for 5 triangles, and then print the...
C++ Create an empty vector in main called theVect. Ask the user for a number. Fill...
C++ Create an empty vector in main called theVect. Ask the user for a number. Fill the vector with 10 random numbers that are multiples of that number. So, for instance, if the user says 7, then you need to use a while loop and fill in the vector with any randomly generated number that is num % 7.
please create a C++ program that will ask the user how many times to roll a...
please create a C++ program that will ask the user how many times to roll a pair of dice. The choices are 10, 20 & 50. Allow the user to select 1 choice and error if none of the choices are valid. The program will then the desired amount. The program will keep track of the running total of the sum of the dice (i.e. 5, 2 = 7; 3,6 =7+9 = 16). The program will then produce the total...
Using the Division Algorithm Create a Java method that does the following: 1) Ask the user...
Using the Division Algorithm Create a Java method that does the following: 1) Ask the user for a dividend and a divisor both of "int" type. 2) Computes the quotient of the division. The quotient (answer) must be of the "int" type. Do NOT use the method " / " provided in Java in your code. Remember that it gives wrong answers when some of the inputs are negative.
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to...
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to guess the number. If the random number is higher than the guess, print "Higher". If the random number is less than the guess, print "Lower". If the random number is equal to the quess, print "Correct!". Create a variable to count the number of guesses and intitialize it to zero. int guesses=0; Increase this variable by 1 every time the user enters a new...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT