Singly Linked List program #1

23. Implement a program to create a node for singly linked list. Read the data for a node, print the node and release the memory of the node.

#include<stdio.h>
#include<stdlib.h>
struct node
{
     int info;
     struct node * link;
};
// typeded struct node Node means using struct node replace with Node bellow
void main()
{
     int x;
     struct node * new;
     new=(struct node * )malloc(sizeof(struct node));
     if(new=='\0')
     {
          printf("Memory is not available\n");
          return;
     }
     else
     {
          printf("Enter data which you want to add\n");
          scanf("%d",&x);
          new->info=x;
          new->link='\0';
          printf("-->%d\n",new->info);
          free(new);
     }
}

Output

    1. Enter data which you want to add
      12
      -->12
       
    


For download this program please check the link ➡➡ Download

Comments

Popular

Basic Program #3

Pointer Program #1

Array Program #4

Basic program #2