Write a program in C to enter the name , Category and the number of hours worked of an employee and then print his name and wages as per the following
Category | Wages per hour (in Rs.) |
---|---|
1 | 100 |
2 | 80 |
3 | 60 |
4 | 300 |
#include< #include< #include< void main() { char name [20]; int cat, hrs; float wages; printf("Enter the name, category, hours worked \n"); scanf("%s %d %d", name, &cat, &hrs); switch(cat) { case 1: wages = hrs * 100; break; case 2: wages = hrs * 80; break; case 3: wages = hrs * 60; break; case 4: wages = hrs * 30; break; default : wages = 0.0; } Printf("Name is %s and wages = Rs. %f \n, name, wages"); } |
---|
For eg :-
Output :-
Enter the name, category, hours worked
Fransis 4 7
Name is Fransis and wages = Rs. 210.000000
0 comments:
Post a Comment