88 Programming and Data Structures
Explanation In the above program a number whose square is to be computed is entered. With
modular division operation last digit is separated to confirm whether it is 5 or not. If yes, the body
of the i f loop is executed where 10 divides the entered number and the quotient is obtained. The
quotient and its consecutive number are multiplied and displayed. Followed by this square of 5 is
calculated and displayed. Care is taken in the printf () statement to display the two results (a)
multiplication of quotient and its consecutive number and b) square of five ) without space. Thus,
the square of a number is displayed.
5.8 Write a program to calculate the salary of medical representative based on the sales.
Bonus and incentive to be offered to him will be based on total sales. If the sale exceeds
Rs.100000/- follow the particulars of Table (1) otherwise (2).
1. TABLE 2. TABLE
Basic= Rs. 3000. Basic= Rs. 3000.
Hra=20% of basic. Hra=20% of basic.
Da= 110% of basic. Da= 110% of basic.
Conveyance=Rs.500. Conveyance=Rs.500.
Incentive=10% of sales. Incentive=5% of sales.
Bonus=Rs. 500. Bonus=Rs. 200.
v o id main()
{
f l o a t b s , h r a , d a, c v , in c e n tiv e , bonus, s a l e , t s ;
clrscr();
printf ("
Enter Total Sales in Rs.:");
scanf &Lsale);
if (sale>=100000)
{
bs=3000;
hra=20 * bs/100;
da= 110 * bs/100;
cv=500;
i ttcen tive=sale *20/100;
bonus=500;
I
else
I
bs=3000;
hra=20 4 bs/100;
da= 110 * bs/100;
cv=500;
incetitive=sale*5/100;
bonus-200;
I
ts=bs+hra+da+cv+incentive+bonus;