Jacob_Thomas

Untitled

Sep 9th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct node{
  5.     int info;
  6.     struct node *next;
  7. }node;
  8.  
  9. node *cll(node *h);
  10.  
  11. int main(){
  12.    
  13.     node *head;
  14.     head=(node*)malloc(sizeof(node));
  15.     head->next=NULL;
  16.     cll(head);
  17.    
  18.    // display(head);
  19.    
  20. }
  21.  
  22. node *cll(node *h){
  23.     int n;
  24.    
  25.    // node *temp;
  26.     node *ptr;
  27.     int i, n1;
  28.     printf("how many\n");
  29.     ptr=h;
  30.     scanf("%d",&n);
  31.     n1=n;
  32.     printf("enter %d val\n ", n);  
  33.     while ( n -- > 0){
  34.              
  35.        
  36.            
  37.             scanf("%d", &ptr->info);
  38.             ptr->next=(node*)malloc(sizeof(node));
  39.             ptr=ptr->next;
  40.             ptr->next=NULL;
  41.        
  42.     }
  43.    
  44.     ptr=h;
  45.     for(i=0;i<n1;i++)
  46.     {
  47.         printf("%d\n", ptr->info);
  48.         ptr=ptr->next;
  49.     }
  50.     return (h);
  51. }
Add Comment
Please, Sign In to add comment