Problem 2: Salesman Contest A company exective wants to arrange a contest and pr
ID: 3606960 • Letter: P
Question
Problem 2: Salesman Contest A company exective wants to arrange a contest and present prizes for the two top most salesmans wh sold highest number of the company goods, such as mobile phones. Write a program in C++ that prompts the user to enter number of contestents and number of goods 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 nunber of contestant ter nunber of sold itens for salesnan 1 432 ter nunber of sold itens for salesnan 2: 150 ter nunber of sold itens for salesnan 3: 359 ter nunber of sold itens for salesman 4: 498 ter nunber of sold itens for salesnan 5: 19 ter nunber of sold itens for salesnan 6: 57 ter nunber of sold itens for salesnan : 61? he Topnost is 617 econdis 14 he Second last is 498Explanation / Answer
#include<iostream.h>
#include<conio.h>
void main()
{
int usize,i,max,smax;
clrscr();
cout<<" Enter the Number of SalesMen :->";
cin>>usize;
//const int size=usize;
int* smen=new int[usize];
for(i=0;i<usize;i++)
{
cout<<" Enter the Number of Sold Item in Salesmen"<<i<<" :->";
cin>>smen[i];
}
max=smen[0];
for(i=0;i<usize;i++)
{
if(smen[i]>max)
{
max=smen[i];
}
}
smax=smen[0];
for(i=0;i<usize;i++)
{
if(smen[i]>max && smax!=max)
{
smax=smen[i];
}
}
cout<<" The Topmos is :->"<<max;
cout<<" The Second Topmos is :->"<<smax;
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.