Professional Documents
Culture Documents
Bijay Sherchan Nepal Students Union Kathmandu Engineering College Kalimati, Kathmandu 9813122278
Bijay Sherchan Nepal Students Union Kathmandu Engineering College Kalimati, Kathmandu 9813122278
Bijay Sherchan Nepal Students Union Kathmandu Engineering College Kalimati, Kathmandu 9813122278
CASE STUDIES
1. SALESMAN'S SALARY
A computer manufacturing company has the following monthly compensation policy to their salespersons:
Minimum base salary
: 1500.00
Bonus for every computer sold
: 200.00
Commission on the total monthly sales : 2 per cent
Since the prices of computers are changing, the sales price of each computer is fixed at the
beginning of every month. A program to compute a sales-person's gross salary is given in
Fig.3.9.
BASE_SALARY
BONUS_RATE
COMMISSION
main()
{
int
float
float
1500.00
200.00
0.02
quantity ;
gross_salary, price ;
bonus, commission ;
= 1000.00
Commission
Gross salary
= 2045.00
= 4545.00
A program to evaluate these roots is given in Fig.3.10. The program requests the user to input the
values of a, b and c and outputs root1 and root2.
<math.h>
a, b, c, discriminant,
root1, root2;
2.00
Root2 = -4.00
Input values of a, b, and c
1 2 3
ROOTS ARE IMAGINARY
Fig.3.10 Solution of a quadratic equation
The term (b2-4ac) is called the discriminant. If the discriminant is less than zero, its square roots
cannot be evaluated. In such cases, the roots are said to be imaginary numbers and the program
outputs an appropriate message.