Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wanted to display the gross sales, salary of each salesperson and determine how many earned salaries in the following categories

$100-$500
$501-900$
$900-above.

Each salesperson(there are 10) receives $100 plus 10% of his gross sasles


C++
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
int main(){
    clrscr();
    int gross_sale[10],i,salary ;
    int ctr1=0,ctr2=0,ctr3=0,r1=5,r2=5,r3=5;
    printf("ENTER GROSS SALES\n");
    
    for(i=0;i<10;i+1){
        printf("Salesperson %d: ",i++);
        scanf("%d",gross_sale[i]);
    
    }
    
    
    clrscr();
    salary=100+gross_sale[i]/10;
    for(i=0;i<10;i++){
    if (salary<500 && salary>100)
    {
        gotoxy(10,r1); printf("Salesperson %d : %d",i+1, salary);
        r1++;ctr1++;
    }
    else if (salary >= 501 && salary <=900){
        gotoxy(35,r2); printf("Salesperson %d : %d",i+1,salary);
        r3++;ctr3++;
    }
    else
    {
        gotoxy(60,r3); printf("Salesperson%d: %d",i+1,salary);
        r3++;ctr3++;
    }
    
    
    printf("\n\n\n");
    printf("Salesperson who earned salaray from $900-and better %d\n",ctr1);
    printf("Salesperson who earned salaray from $500-$900 %d\n",ctr2);
    printf("Salesperson who earned salaray from $100-$500 %d\n",ctr3);
    
    gotoxy(24,1);
    printf("SALARY CATEGORIES\n");
    printf("\n[$100-$500]\t\t[$501-$900]\t\t[$901 and better]");
    
    
    getch();
    return 0;
    }
}
</conio.h></stdio.h></iostream.h>
Posted
Updated 30-Sep-15 13:04pm
v3
Comments
George Jonsson 30-Sep-15 19:44pm    
So what is your question?
In which line does the error occur?

1 solution

You will not learn C language by asking every single detail as you encounter a problem .
You really need to follow a few tutorials they are here to teach you how things works, you are not to follow blindly, you have to try to understand why things are done the way they are shown, to you.

For the title question:
See how you used n in your previous program, for the scan function.
C++
scanf("%d", &n) ;

You used & to say that you want the adress of n. Why would it be otherwise in new program ?
C++
scanf("%d", gross_sale[i]);

I let you guess what should be done.

This error is not the only one, use the debugger to see what is wrong.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900