Advertisement
SAADQUAMER

Signly_min

Oct 29th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. typedef struct node
  5. {
  6.  
  7.     int a;
  8.     struct node *next;
  9. } node;
  10.  
  11. node *head=NULL;
  12. void insert_end(int aN)
  13. {
  14.     node *N=(node*)malloc(sizeof(node));
  15.     N->a=aN;
  16.     N->next=NULL;
  17.     if(head==NULL)
  18.     {
  19.         head=N;
  20.     }
  21.     else
  22.     {
  23.         node *list=head;
  24.         while(list->next!=NULL)
  25.         {
  26.             list=list->next;
  27.         }
  28.         list->next=N;
  29.     }
  30. }
  31.  
  32. void display()
  33. {
  34.  
  35.     node*list=head;
  36.  
  37.  
  38.     int k=list->a;
  39.  
  40.     while(list!=NULL)
  41.     {
  42.  
  43.         if(k>list->a)
  44.         {
  45.             k=list->a;
  46.         }
  47.  
  48.         list=list->next;
  49.     }
  50.      printf("\nMin VALUE IS : %d\n",k);
  51. }
  52.  
  53. int main()
  54.  
  55. {
  56.     int n,x,i;
  57.     head=NULL;
  58.     printf("Input the Number of Node:");
  59.     scanf("%d",&n);
  60.     for(i=0; i<n; i++)
  61.     {
  62.         scanf("%d",&x);
  63.         insert_end(x);
  64.  
  65.     }
  66.     display();
  67.  
  68.     return;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement