View Single Post
Old 19-03-2008, 08:15 PM   #422 (permalink)
baccilus
Alpha Geek
 
baccilus's Avatar
 
Join Date: Feb 2006
Location: Chandigarh
Posts: 947
Default Re: Post ur C/C++ Programs Here

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.
__________________
Appreciate me now and avoid the rush!!
i5 2500K || 8GB DDRIII 1600 MHz RAM || Zotac GTX560Ti || Samsung 2233sw || Corsair GS600
baccilus is offline