Ask Question

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

+5
Answers (1)
  1. 8 November, 12:11
    0
    Following are the program in c++

    #include / / header file

    using namespace std; / / namespace

    int main () / / main function

    {

    double a, b; / / variable declaration

    cout<<"Enter the first number and second number : / n";

    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

    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".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a C+ + program that allows the user to enter double values. Display one of two messages: "The first number you entered is larger", ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers