Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<malloc.h>
  4. #include<string.h>
  5. struct emp *addemp(struct emp*,char q[20],char desi[20],int,float);
  6. void display(struct emp*);
  7. struct emp
  8. {
  9. char name[20];
  10. char desi[20];
  11. int accno;
  12. float bal;
  13. struct emp *ptr;
  14. };
  15. int main()
  16. {
  17. int i,accountno,size=5;
  18. char name[20],desi[20];
  19. float balance;
  20. struct emp *head;
  21. head=NULL;
  22. for(i=0;i<=size;i++)
  23. {
  24. printf("enter the name :\n",i);
  25. scanf("%s",name);
  26. printf("enter the designation :\n",i);
  27. scanf("%s",desi);
  28. printf("enter the account no: \n");
  29. scanf("%d",&accountno);
  30. printf("Enter the balance: \n");
  31. scanf("%f",&balance);
  32. head=addemp(head,name,desi,accountno,balance);
  33. }
  34. display(head);
  35. }
  36. struct emp *addemp(struct emp *head,char n[20],char desi[20],int a,float b)
  37. {
  38. struct emp *newnode;
  39. newnode=(struct emp *)malloc(sizeof(struct emp));
  40. strcpy(newnode->name,n);
  41. strcpy(newnode->desi,desi);
  42. newnode->accno=a;
  43. newnode->bal=b;
  44. if(head==NULL)
  45. {
  46. newnode->ptr=NULL;
  47. return newnode;
  48. }
  49. else
  50. {
  51. newnode->ptr=head;
  52. return newnode;
  53. }
  54. }
  55. void display(struct emp *head)
  56. {
  57. while(head!=NULL)
  58. {
  59. printf("name=%s\t destination=%s accno=%d\t bal=%f \n",head->name,head->desi,head->accno,head->bal);
  60. head=head->ptr;
  61. }
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top