c program of linked list education info


SUBMITTED BY: deymen

DATE: July 24, 2016, 4:54 p.m.

FORMAT: Text only

SIZE: 809 Bytes

HITS: 3580

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. struct node
  5. {
  6. int data;
  7. struct node *next;
  8. }*start=NULL;
  9. void create()
  10. {
  11. char ch;
  12. do
  13. {
  14. struct node *current,*new_node;
  15. new_node=(struct node*)malloc(sizeof(struct node));
  16. printf("\n enter the data to node");
  17. scanf("%d",&new_node->data);
  18. new_node->next=NULL;
  19. if(start==NULL)
  20. {
  21. start=new_node;
  22. current=new_node;
  23. }
  24. else
  25. {
  26. current->next=new_node;
  27. current=new_node;
  28. }
  29. printf("\n do you want to create another node:");
  30. ch=getche();
  31. }while(ch!='n');
  32. }
  33. void display()
  34. {
  35. struct node*temp=start;
  36. printf("\n the linked list is :");
  37. while(temp!=NULL)
  38. {
  39. printf("%d--->",temp->data);
  40. temp=temp->next;
  41. }
  42. printf("NULL");
  43. }
  44. void main()
  45. {
  46. create();
  47. display();
  48. }

comments powered by Disqus