Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List
offline chennai batch 1 karthick
in linked list adding one node and deleting node
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
void print(struct node *a);
int main()
{
struct node *temp=NULL;
struct node *head;
struct node *one = NULL;
struct node *two = NULL;
struct node *three = NULL;
one = malloc(sizeof(struct node));
two = malloc(sizeof(struct node));
three = malloc(sizeof(struct node));
printf("one->data =");
fflush(stdout);
scanf("%d",&one->data);
printf("two->data =");
fflush(stdout);
scanf("%d",&two->data);
printf("three->data =");
fflush(stdout);
scanf("%d",&three->data);
one->next = two;
two->next = three;
three->next = NULL;
head = one;
print(head);
struct node *four = NULL;
four = malloc(sizeof(struct node));
printf("\n four->data =");
fflush(stdout);
scanf("%d",&four->data);
three->next = four;
four->next = NULL;
head = one;
print(head);
printf("\n");
three->data=NULL;
two->next=four;
print(head);
}
void print(struct node *a)
{
while (a!=NULL)
{
printf("%d",a->data);
a=a->next;
}
}