Ask Question
15 May, 07:11

Write a C+ + program which prompts the user to enter some numbers and finds the largest number of those entered. Entering 0 should terminate the sequence of numbers and cause the largest number found to be displayed.

+5
Answers (1)
  1. 15 May, 10:45
    0
    Following are the program in c++

    #include / / header file

    using namespace std; / / using namespace

    int main () / / main method

    {

    int number, maximum; / / variable declaration

    cout << "Entering the number 0 will terminate the program:/n";

    do{

    cin >> number; / / read the number

    if (number = = 0) / / check the condition if number is 0

    break;

    if (maximum < number) / / finding the maximum number

    maximum = number; / / assign the number to maximuim variable

    }while (true);

    cout << "The largest of the numbers is : " << maximum << endl;

    }

    Output:

    Entering the number 0 will terminate the program:

    19

    56

    560

    6

    0

    The largest of the numbers is : 560

    Explanation:

    In this Program we read the number from the user in the do while loop. The loop will iterating untill user is not entered 0 also it checks the condition of finding maximum number in that loop by using if (maximum < number) statement in this condition it store the maximum number in maximum variable.

    if user is entered 0 the loop will terminated and Print the maximum number.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a C+ + program which prompts the user to enter some numbers and finds the largest number of those entered. Entering 0 should ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers