Hello again. doing a question in which I am to read the gross sales of a sales person and calculate their salary , which is 200 + 9% of gross salary. Then I am to count the number of workers between 200 and 299 salary etc. My solution compiles. But when I run it seems to be working but it reports all salaries as 0. I'm sure I've made a simple mistake somewhere but i am unable to find it. Hopefully someone could help me. Thanks.
Code:
#include<stdio.h>
#include<stdlib.h>
#define SIZE 100
int main()
{
float salary[SIZE];
float sales[SIZE];
int i , j , num , counter;
int r = 0;
int limitDown = 200;
int limitUp = 300;
printf("Enter number of people in company(must not exceed 100)\n");
do
{
scanf("%d" , &num);
if ((num > 100) || (num < 0))
{
printf("Number of people cannot exceed 100 or be below 0, enter again:\n");
}
}while((num > 100) || (num < 0));
for (i = 0; i < num; i++);
{
printf("Enter a workers gross sales\n");
scanf("%f" , &sales[i]);
salary[i] = 200 + (0.9 * sales[i]);
}
for(i = 0; i < 9; i++)
{
for(j = limitDown; j < limitUp; j++)
{
for(counter = 0; counter < num; counter++)
{
if (limitDown < 1000)
{
if ((salary[counter] >= limitDown) && (salary[counter] < limitUp))
{
r++;
}
}
else
{
if(salary[counter] >= limitDown)
{
r++;
}
}
}
}
if (limitDown < 1000)
{
printf("Number of people salaries %d and %d : %d\n" , limitDown , limitUp - 1 , r);
}
else
{
printf("Number of people salaries %d and beyond: %d\n" , limitDown , r);
}
limitUp += 100;
limitDown += 100;
r = 0;
}
system("PAUSE");
return 0;
}