Sunday 13 December 2015

WAP to define a structure with the following specification

 WAP to define a structure with the following specification
            Structure name            Emp
            Ecode                          integer                                    
            Ename                         character array
            Basic salary                 float
            Hra                              float                             40% of basic salary
            Da                               float                             20% of basic salary
            Ta                                float                             10% of basic salary
            Gross salary                 float                             basic salary + hra + da + ta
            It                                 float                             20 % of gross salary   
            Pf                                float                             10% of gross salary

            Net salary                    float                             gross salary – (it + pf)


#include<stdio.h>
#include<conio.h>
struct emp
{int ecode;
char ename[1000];
float sal;
float hra;
float da;
float ta;
float gs;
float it;
float pf;
float netsal;
};
void main()
{
struct emp e;
clrscr();
printf("enter info of emp");
printf("enter name ");
scanf("%s",e.ename);
printf("enter emp code");
scanf("%d",&e.ecode);
printf("enter sal to find hra,da,ta,gs,it,pf,netsal");
scanf("%f",&e.sal);
e.hra=(e.sal*40)/100;
e.da=(e.sal*20)/100;
e.ta=(e.sal*10)/100;
e.gs=(e.sal+ e.hra+e.da+e.ta);
e.it=(e.gs*20)/100;
e.pf=(e.gs*10)/100;
e.netsal=(e.gs-(e.it+e.pf));
printf("\ninfo\n");
printf("name: %s\n",e.ename);
printf("code: %d\n",e.ecode);
printf("sal: %f\n",e.sal);
printf("hra: %f\n",e.hra);
printf("da: %f\n",e.da);
printf("ta: %f\n",e.ta);
printf("gs: %f\n",e.gs);
printf("it: %f\n",e.it);
printf("pf: %f\n",e.pf);
printf("netsal: %f\n",e.netsal);
getch();
}

No comments:

Post a Comment