BEST SALES PERSON (ID-3469)
A company stores the name, age and sales made in five cities of their salespersons, given the details of ‘n’ employees, write an algorithm and the C program to find the best sales person. Best sales person is the one who has made maximum sales in the company. For example given the details of six salespersons with the following details:
SP1, 34, 45, 18, 22, 38, 37
SP2, 32, 46, 15, 23, 35, 29
SP3, 29, 47, 16, 30, 35, 35
SP4, 31, 49, 12, 32, 36, 40
SP5, 23, 45, 11, 30, 35, 39
SP6, 29, 41, 15, 31, 33, 37
Then the best salesperson is SP4.
Input Format
First line contains the number of salespersons, n
Next n lines contain the details of ‘n’ salespersons such as name, age and sales made by the salesperson in five cities separated by space
Output Format
Print the name of the best sales person
sol:-
//byvitcrack
#include<stdio.h>
#include<stdio.h>
struct sales{
char a[30];
int age,c1,c2,c3,c4,c5; };
void main()
{int i,n,l,max;
scanf("%d",&n);
struct sales b[n];
int c[n];
for(i=0;i<n;i++)
{scanf("%s",b[i].a);
scanf("%d",&b[i].age);
scanf("%d",&b[i].c1);
scanf("%d",&b[i].c2);
scanf("%d",&b[i].c3);
scanf("%d",&b[i].c4);
scanf("%d",&b[i].c5);
c[i]=b[i].c1+b[i].c2+b[i].c3+b[i].c4+b[i].c5;}
max=c[0];
for(i=0;i<n;i++)
{if(c[i]>max)
{max=c[i];
l=i;}}
printf("%s",b[l].a);}
0 Comments