29.6k views
0 votes
Write a program that inputs a series of 10 non-negative numbers and determines and prints the largest of those numbers. Your program should use three variables: Counter - a counter to count to 10 (i.e. to keep track of how many numbers have been input and to determine when all 10 number have been processed) Number - the current number input to the program Largest - the largest number found so far

User Docconcoct
by
4.8k points

1 Answer

4 votes

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int Counter,largest=-1,Number;

cout<<"enter 10 non-negative numbers:";

// read 10 non-negative Numbers

for(Counter=1;Counter<=10;Counter++)

{

cin>>Number;

if entered number is largest so far

if(Number>largest)

{

// update the largest

largest=Number;

// print the largest

cout<<"largest found so far is: "<<largest<<endl;

}

}

return 0;

}

Step-by-step explanation:

Declare variables Counter,Number and largest=-1.Here Counter is use to keep count of input number.largest to store the largest input so far.And Number to read inout from user.Find and print largest after each input.

Output:

enter 10 non-negative numbers:24

largest found so far is: 24

12

56

largest found so far is: 56

9

8

67

largest found so far is: 67

33

56

98

largest found so far is: 98

100

largest found so far is: 100

User Roman Kiss
by
4.9k points