1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nonamiya [84]
3 years ago
10

(Occurrence of max numbers) Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume t

hat 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 max and reset count 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 Sample Run 2 Enter an integer (0: for end of input): 0 No numbers are entered except 0 Class Name: Exercise05_41
Computers and Technology
1 answer:
tankabanditka [31]3 years ago
5 0

Answer:

Following are the code to the given question:

#include <iostream>//header file

using namespace std;

int main() //main method

{

int n=0,a[1000],c=0,val=10,ma=0;//defining integer variable

cin>>val;//input value

while(val!=0)//defining while loop that checks val is not equal to 0

{

a[n++]=val;//add value in array

cout<<"Enter an integer (0: for end of input):";//print message

cin>>val;//input value

}

for(int i=0;i<n;i++)//loop for finding the maximum in the array.

{

   ma=max(a[i],ma);//holding max value in ma variable

}

for(int i=0;i<n;i++)//loop for counting the occurence of maximum.

{

   if(a[i]==ma)//use if to check maximum value in array

   c++;//incrementing count value

}

cout<<"The maximum value is "<<ma<<" The count of maximum value is "<<c<<endl;//print result

return 0;

}

output:

Please find the attachment file.

Explanation:

In this code inside the main method, an integer variable is declared that input values and use while loop to check first input if the value is true it will accept value from the user and adds in the array.

In the next step, two for loop is declared that checks the max value and in the next loop it will count the number of maximum value which is occurring.

You might be interested in
What is artificial Intelligence ?
Charra [1.4K]

Answer:

Artificial intelligence (AI) is intelligence demonstrated by machines, unlike the natural intelligence displayed by humans and animals, which involves consciousness and emotionality. The distinction between the former and the latter categories is often revealed by the acronym chosen. 'Strong' AI is usually labelled as artificial general intelligence (AGI) while attempts to emulate 'natural' intelligence have been called artificial biological intelligence (ABI). Leading AI textbooks define the field as the study of "intelligent agents": any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals.Colloquially, the term "artificial intelligence" is often used to describe machines that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem solving".

As machines become increasingly capable, tasks considered to require "intelligence" are often removed from the definition of AI, a phenomenon known as the AI effect.A quip in Tesler's Theorem says "AI is whatever hasn't been done yet." For instance, optical character recognition is frequently excluded from things considered to be AI,having become a routine technology. Modern machine capabilities generally classified as AI include successfully understanding human speech,]competing at the highest level in strategic game systems (such as chess and Go), and also imperfect-information games like poker,[11] self-driving cars, intelligent routing in content delivery networks, and military simulations.

Artificial intelligence was founded as an academic discipline in 1955, and in the years since has experienced several waves of optimism,followed by disappointment and the loss of funding (known as an "AI winter") followed by new approaches, success and renewed funding.[ After AlphaGo successfully defeated a professional Go player in 2015, artificial intelligence once again attracted widespread global attention.For most of its history, AI research has been divided into sub-fields that often fail to communicate with each other. These sub-fields are based on technical considerations, such as particular goals (e.g. "robotics" or "machine learning"),the use of particular tools ("logic" or artificial neural networks), or deep philosophical differences. Sub-fields have also been based on social factors (particular institutions or the work of particular researchers

Explanation:

<h2>Hopefully u will satisfy with my answer of ur question..!!</h2>

<h2>Please Mark on brainleast please..!!</h2>

<h2>Have a nice day ahead dear..!!</h2>

4 0
3 years ago
Read 2 more answers
When you right-click certain areas of the Word or other Office app windows, a command menu will appear. Group of answer choices
klasskru [66]

Answer:

The answer is "False".

Explanation:

In the word or other office application when we right-click on a certain area of the office, it will provide a common task, like double-click and pick objects.

  • The right mouse button also refers to use and open the pop-up menu, which changes depending on where you select.
  • It allows the computer to mouse additional features, typically known as an optional lowering screen, that's why the given statement is "false".
3 0
4 years ago
Difference between multidimensional arrays and an example​
weqwewe [10]

Answer:

The generic data structure of a n-dimensional array is a tensor.

An example with 3 dimension can be a cube that contains the following dimensions: users, items, time. That cube can represent the interactions of  users with verifiied pages of public interests (influencers or company/media pages) in time slots (e.g. weekly timeslots).

Explanation:

You can represent in a sparse 3-dimensional array (tensor) the combinations of which user interacted with wich item in a given timeslow.

5 0
3 years ago
The purpose of a function that does not return a value is
tatuchka [14]

Answer:

The answer to the given question is the option "a".

Explanation:

A function is a block of organized code that provides the reusability of the code. It is used to perform a separate, complex action. In programming languages name is different like, functions, methods, subroutines, procedures, etc. but the working of the function is the same. The purpose of the function that does not return a value is the option "a" and All the options are correct.  

5 0
3 years ago
What is the correct syntax to take the first five characters from the cell and place to its right in cell A3?
olga nikolaevna [1]

Answer:

In cell A3 we type

=Right(A2,5)

Explanation:

The Right function in the Microsoft excel is placing the character or the string into the right position .Following are the syntax to using the right function in the excel sheet

=Right(cell name,num _of_character )

  • cell name-In this we have to specify the cell name
  • num_of_character -In this we have to specify the number of character we want the right of the cell name .

From the given question We have putting the string in the cell A2 and we have used the function in the cell A3 i.e

=Right(A2,5)

4 0
3 years ago
Other questions:
  • What's the minimum number of ip addresses that a router must have?
    6·1 answer
  • How do you scan a qr code on your iPhone
    5·2 answers
  • Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment v
    5·1 answer
  • How to find determinant of ​
    15·1 answer
  • In which step of web design is storyboarding helpful?
    14·1 answer
  • Which element of the Word program window displays information about the current document, such as number of pages, and also incl
    14·1 answer
  • Why concurrency control is needed in transaction.
    5·1 answer
  • when files on storage are scattered throughout different disks or different parts of a disk, what is it called
    10·1 answer
  • ____ is an example of a set of prewritten classes that allows you to access data stored in a database.
    8·1 answer
  • What type of email communication reaches out to former clients and older prospects and encourages a reply? Strategic email Onboa
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!