1)Write a C program using data structure to accept the detail of employee from the user and display it on the screen using dynamic memory allocation.


#include<stdio.h>
#include<conio.h>
struct emp
{
int eno;
char ename[10];
float sal;
};
void linkfloat()
{
float a=0,*b;
b=&a;
a=*b;
}
void main()
{
struct emp *e;
int n,i;
clrscr();
printf(“\nEnter the Size \n”);
scanf(“%d”,&n);
e=(struct emp *)calloc(n,sizeof(struct emp));
printf(“\nEnter the Eno,EName, ESal \n”);
for(i=0;i<n;i++)
{
scanf(“%d%s%f”,&e[i].eno,&e[i].ename,&e[i].sal);
}
printf(“\n\nDetails of Employee \n\n”);
for(i=0;i<n;i++)
{
printf(“\n\n%d\t%s\t%f”,e[i].eno,e[i].ename,e[i].sal);
}
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s