SHARE
TWEET

maxvalue

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