hi,my program calculate the salary of salesperson,but gets(name) doesnt give the name?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
char name[100];
int sales[100],k=0,n,first=0,second=0,third=0,fourth=0,fifth=0;
double salary[100];
printf("how many salesperson in this company = ");
scanf("%d",&n);
//given the informations of salespersons...
for(int i=0; i<n;i++)
{
//printf("Name of salesperson = ");
gets(name); //here doesnt give the name
printf("\nSales of salesperson = ");
scanf("%d",&sales[i]);
salary[i]=sales[i]*0.8+100;
}
//make equal space ...
for(int i=0;i<n;i++)
for(int j=0;j<=40;j++)
name[i]=' '+name[i];
//draw first table ...
for(int i=0;i<n;i++)
{
while(name[k] !='\0')
{
putchar(name[k]);
if(k==40)
{
printf("$ %d |$ %d",sales[i],salary[i]);
k++;
}
}
printf("\n");
}
//the range of salary ...
for(int i=0; i<n; i++)
{
if(100<= salary[i] && salary[i]<300)
first++;
else if(300<= salary[i] && salary[i]<500)
second++;
else if(500<= salary[i] && salary[i]<700)
third++;
else if(700<= salary[i] && salary[i]<900)
fourth++;
else
fifth++;
}
//draw second table ...
printf(" ----------------------------- \n");
printf("| range |number of sales people |\n");
printf("|-----------------------------|\n");
for(int i=0;i<5;i++)
{
switch(i)
{
case 0: printf("| 100$ - 299$ | %d |\n",first); break;
case 1: printf("| 300$ - 499$ | %d |\n",second); break;
case 2: printf("| 500$ - 699$ | %d |\n",third); break;
case 3: printf("| 700$ - 899$ | %d |\n",fourth); break;
case 4: printf("| 900$ and over | %d |\n",fifth); break;
}
printf("|-----------------------------|\n");
}
system("pause");
return 0;
}
thank you for helping.