Here's a program to calculate the computer sales man salary. Base salary, bonus rate and commission are fixed. Input of price per system and number of systems sold is from user.
Code:
#include<stdio.h>
#define BASE_SAL 2000.0
#define BONUS 200.0
#define COMMISSION 0.02
//Compiled on linux using geany
int main()
{
int n;
float bonus, commission, price;
float gross_sal;
printf("\nInput the number of systems sold ",n);
scanf("%d",&n);
printf("\nInput the price of each computer ",price);
scanf("%f",&price);
bonus=BONUS*n;
commission=COMMISSION*price*n;
gross_sal=BASE_SAL+bonus+commission;
printf("Base salary is %f\nBonus is %f\nCommission is %f\nGross salary is %f"
,BASE_SAL,commission,gross_sal);
}
Gross salary is coming out to be wrong but I don't know why. Please tell if you realize that.