Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Saturday, January 9, 2010

Using the switch .... case statement. Write a program in C

Write a program in C to enter employee name his categories and basic pay then calculate and print his net salary with the formula
net salary (ns) = basic pay (bp) + hra - pf.
where hra and pf are calculated as per the following rules.

















Categoryhra
pf
o - officer
15% of bp
9% of bp
m - manager
10% of bp
8% of bp
w - worker
5% of bp
7% of bp




#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
char cat, name [20];
float bp, hra, pf, ns;
clrscr();
printf("Enter employee name, category and basic pay \n");
scanf("%s %c %f", name, &cat, &bp);
switch(cat)
{
case 'o' :
hra = bp * 0.15;
pf = bp * 0.09;
break;

case 'm' :
hra = bp * 0.1;
pf = bp * 0.08;
break;

case 'w' :
hra = bp * 0.05;
pf = bp * 0.07;
break;

default :
hra = 0.0;
pf = 0.0;
}
ns = bp + hra - pf;
printf("Net salary = Rs. %f \n", ns);
}

For eg :-

Output :-
Enter employee name, category and basic pay
Fransis 0 10000
Net salary = Rs. 10600.000000

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP