Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<malloc.h>
- #include<string.h>
- struct emp *addemp(struct emp*,char q[20],char desi[20],int,float);
- void display(struct emp*);
- struct emp
- {
- char name[20];
- char desi[20];
- int accno;
- float bal;
- struct emp *ptr;
- };
- int main()
- {
- int i,accountno,size=5;
- char name[20],desi[20];
- float balance;
- struct emp *head;
- head=NULL;
- for(i=0;i<=size;i++)
- {
- printf("enter the name :\n",i);
- scanf("%s",name);
- printf("enter the designation :\n",i);
- scanf("%s",desi);
- printf("enter the account no: \n");
- scanf("%d",&accountno);
- printf("Enter the balance: \n");
- scanf("%f",&balance);
- head=addemp(head,name,desi,accountno,balance);
- }
- display(head);
- }
- struct emp *addemp(struct emp *head,char n[20],char desi[20],int a,float b)
- {
- struct emp *newnode;
- newnode=(struct emp *)malloc(sizeof(struct emp));
- strcpy(newnode->name,n);
- strcpy(newnode->desi,desi);
- newnode->accno=a;
- newnode->bal=b;
- if(head==NULL)
- {
- newnode->ptr=NULL;
- return newnode;
- }
- else
- {
- newnode->ptr=head;
- return newnode;
- }
- }
- void display(struct emp *head)
- {
- while(head!=NULL)
- {
- printf("name=%s\t destination=%s accno=%d\t bal=%f \n",head->name,head->desi,head->accno,head->bal);
- head=head->ptr;
- }
- }
Add Comment
Please, Sign In to add comment