A company exective wants to arrange a contest and present prizes for the two top
ID: 3597358 • Letter: A
Question
A company exective wants to arrange a contest and present prizes for the two top most salesmans who sold highest number of the company goods, such as mobile phones sold by each salesman. The program then selects and prints the top two salesmans based on the number of goods sold. Sample input / output: ter number of contestants 7 ter number of sold items for salesnan 1: 432 ter number of sold items for salesnan 2: 150 ter number of sold items for salesnan 3: 359 ter number of sold items for salesan 4: 498 ter number of sold items for salesnan 5 19 Enter number of sold items for salesnan 6: 57 Enter number of sold items for salesnan 7: 617 The Topnost is 61? The Second last is 498Explanation / Answer
Don't use i+1 inside the loop as it is unnecessary and to make the program will work when you will change the top only when items>top. As in this program the items is not included in the if statement so it is changed everytime to items when the loop is running so you need to change top to items only when items is bigger than top for that use the following if statement
if(items>top)
{
top2=top;
top=items;
}
Please do upvote this answer and if you have any doubts leave a comment.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.