Structure

// Structure for salary sheet
#include<stdio.h>
#include<conio.h>
void main()
{
struct semp
{
unsigned int n,b,d,t,h,p,g;
char m[20];
};
struct semp a;
clrscr();
printf("\n Enter a no:-");
scanf("%u",&a.n);
flushall();
printf("\n Enter a name:-");
gets(a.m);
printf("\n Enter basic salary:-");
scanf("%u",&a.b);
a.d=a.b*0.10;
a.h=a.b*0.12;
a.t=a.p=a.b*0.15;
a.g=a.d+a.h+a.t;
printf("\n Employee no:-%u \n Employee name:-%s \n Basic salary:-%u \n DA:-%u \n HRA:-%u \n TA:-%u \n PF:-%u \n Gross salary:-%u",a.n,a.m,a.b,a.d,a.h,a.t,a.p,a.g);
getch();
}
----------------------------------------
//Structure for students
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
int r,m1,m2,m3,t,a;
char n[20];
};
struct student k;
clrscr();
k.t=0;
k.a=0;
printf("\n Enter roll no:-");
scanf("%d",&k.r);
printf("\n Enter a name:-");
scanf("%s",&k.n);
printf("\n Enter mark 1:-");
scanf("%d",&k.m1);
printf("\n Enter mark 2:-");
scanf("%d",&k.m2);
printf("\n Enter mark 3:-");
scanf("%d",&k.m3);
k.t=k.m1+k.m2+k.m3;
k.a=k.t/3;
printf("\n Roll no:-%d \n Name:-%s \n Total of marks is %d \n Average is %d",k.r,k.n,k.t,k.a);
(k.m1>33&&k.m2>33&&k.m3>33)?(k.a>70)?printf("\n You got A grade"):(k.a>50)?printf("\n You got B grade"):(k.a>33)?printf("\n You got C grade"):printf("\n You are failed"):printf("\n You are failed");
getch();
}

No comments:

Post a Comment