N C++ PLEASE Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume that the input ends with number 0. Suppose that you entered 3 5 2 5 5 5 0; the program finds that the largest is 5 and the occurrence count for 5 is 4. Hint: Maintain two variables, max and count . max stores the current max number and count stores its occurrences. Initially, assign the first number to max and 1 to count . Compare each subsequent number with max . If the number is greater than max , assign it to to 1 . If the number is equal to max , increment count by 1 . Sample Run 1 Enter an integer (0: for end of input): 3 Enter an integer (0: for end of input): 5 Enter an integer (0: for end of input): 2 Enter an integer (0: for end of input): 5 Enter an integer (0: for end of input): 5 Enter an integer (0: for end of input): 5 Enter an integer (0: for end of input): 0 The largest number is 5 The occurrence count of the largest number is 4

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

IN C++ PLEASE

Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume that the input ends with number 0. Suppose that you entered 3 5 2 5 5 5 0; the program finds that the largest is 5 and the occurrence count for 5 is 4.

Hint: Maintain two variables,

max

and

count

.

max

stores the current max number and

count

stores its occurrences. Initially, assign the first number to

max

and

1

to

count

. Compare each subsequent number with

max

. If the number is greater than

max

, assign it to

to

1

. If the number is equal to

max

, increment count by

1

.

Sample Run 1

Enter an integer (0: for end of input): 3

Enter an integer (0: for end of input): 5

Enter an integer (0: for end of input): 2

Enter an integer (0: for end of input): 5

Enter an integer (0: for end of input): 5

Enter an integer (0: for end of input): 5

Enter an integer (0: for end of input): 0

The largest number is 5

The occurrence count of the largest number is 4



Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,