157k views
4 votes
Write a C++ program that allows the user to enter double values. Display one of two messages: "The first number you entered is larger", "The second number you entered is larger". Save file as LargerorNot.cpp

User Hln
by
4.0k points

1 Answer

7 votes

Answer:

Following are the program in c++

#include <iostream> // header file

using namespace std; // namespace

int main() // main function

{

double a,b; // variable declaration

cout<<"Enter the first number and second number : \\";

cin>>a>>b; // input the number

if(a>b) // check first number greater than second number

{

cout<<"The first number you entered is larger";

}

else

{

cout<<"The second number you entered is larger";

}

return 0;

}

Output:

Enter the first number and second number :

45.5

687.8

The second number you entered is larger

Step-by-step explanation:

In this program we have declared two variable i.e a and b of double type. After that check the condition if(a>b) if this condition is true then display the message "The first number you entered is larger " otherwise display the message "The second number you entered is larger".

User Verklixt
by
4.9k points