15 November 2011

a program in DSA as employee que


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct employee
{
int emp_id;
char emp_name[15];
int bs;
float gs;
struct employee *next;
};
struct queue
{
struct employee *rear;
struct employee *front;
};
void main()
{
int bs;
float ta,da,hra,gs;
struct employee *emp1;
struct queue *queue1;
char ch='y';
clrscr();
queue1=NULL;
while(ch=='y')
{
emp1= malloc(sizeof (struct employee));
if (queue1==NULL)
{
queue1->front=queue1->rear=emp1;
}
else
{
queue1->front=emp1;
queue1->front=queue1->front->next;
}
queue1->front->next=NULL;
printf("\n Enter employee id : ");
scanf("%d",& emp1->emp_id);
printf("\n Enter employee name :");
scanf("%s",& emp1->emp_name);
printf("\n Enter basic salary :");
scanf("%d",& emp1->bs);
ta=0.20*bs;
da=0.40*bs;
hra=0.15*bs;
gs=bs+ta+da+hra;
printf("\n\t Gross salary of employee is : %f",gs);
printf("\n\n\t Enter your choice(y/n) :");
fflush(stdin);
scanf("%c",& ch);
}
for(  ;queue1->front!=NULL;queue1->front=queue1->front->next)
{
printf("\n emp_id = %d",emp1->emp_id);
printf("\n emp_name = %s",emp1->emp_name);
printf("\n basic salary = %d",emp1->bs);
printf("\n gross salary = %f\n",gs);
}
if(gs>15000)
{
printf("\n\tGross salary is more than 15000");
}
else
{
printf("\n\tGross salary is less than 15000");
}
getch();
}

0 comments:

Post a Comment