An Overview

All the necessary study material for b-tech students.

What we have to offer you.

Codes,Syllabus,Study material,Lab manuals,Assignments and many more . . .

Surfing becomes easy.

You can have any material from our website and post your valuable comments for further improvement.

Get the latest techno news

Get yourself updated with this fast changing dynamic world and all the changes in b-tech pattern.

All the best resources for you.

We have done our level best to provide you with the best of the degree and thus this site is devoted to b-tech exclusively.

Showing posts with label que. Show all posts
Showing posts with label que. Show all posts

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();
}

A DSA program showing que.


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int info;
struct node*next;
};
struct queue
{
struct node*rear;
struct node *front;
};
void main()
{
struct node *node1;
struct queue *queue1;
char ch='y';
queue1=NULL;
while(ch=='y')
{
node1=malloc(sizeof(struct node));
if(queue1==NULL)
{
queue1->front=queue1->rear=node1;
}
else
{
queue1->front=node1;
queue1->front=queue1->front->next;
}
queue1->front->next=NULL;
printf("\n enter any value ") ;
scanf("%d",&node1->info) ;
printf("\n do you want to more press your choice(Y/N) :") ;
fflush(stdin);
scanf("%c",&ch);
}
for( ;queue1->front!=NULL;queue1->front=queue1->front->next)
{
printf("%d",queue1->front->info);
}
getch();
}