Write a 'C' Program using data structure to accpet the details of Emplyees from User and Display it on Screen Using Dynamic Memory Allocation


#include<stdio.h>

#include<conio.h>

#include<alloc.h>

struct emp

{

int eno;

char ename[20];

char address[20];

};

void main()

{

int i,n;

struct emp *record;

clrscr();

printf("\n Enter How Many Records: ");

scanf("%d",&amp;n);

record=(struct emp*)malloc(n*sizeof(struct emp));

if(record==NULL)

{

printf("\n Insufficient Memory.");

exit(0);

}

for(i=0;i&lt;n;i++)

{

printf("\n Enter EMPNO: ");

scanf("%d",&amp;record[i].eno);

printf("\n Enter EmpName: ");

scanf("%s",record[i].ename);

printf("\n Enter Address ");

scanf("%s",record[i].address);

}

printf("\n EMPNO   EMPNAME   ADDRESS\n");

for(i=0;i&lt;n;i++)

{

printf("\n %d   %s   %s   \n",record[i].eno,record[i].ename,record[i].address);

}

getch();

}



/*OUTPUT


 Enter How Many Records: 2                                                     

                                                                               

 Enter EMPNO: 1                                                                

                                                                               

 Enter EmpName: Raj                                                            

                                                                               

 Enter Address Mumbai                                                          

                                                                               

 Enter EMPNO: 2

                                                                               

 Enter EmpName: Dinesh


 Enter Address Delhi


 EMPNO   EMPNAME   ADDRESS


 1   Raj   Mumbai


 2   Dinesh   Delhi */
Write a 'C' Program using data structure to accpet the details of Emplyees from User and Display it on Screen Using Dynamic Memory Allocation Write a 'C' Program using data structure to accpet the details of Emplyees from User and Display it on Screen Using Dynamic Memory Allocation Reviewed by on November 16, 2013 Rating: 5
Powered by Blogger.