Untitled
Kaustav
plain_text
4 years ago
958 B
15
Indexable
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct Node *next;
};
struct Node *front=NULL;
struct Node *rear=NULL;
void Insert(int x){
struct Node* temp = (struct Node*)malloc(sizeof(struct Node));
temp->data=x;
temp->next=NULL;
if(front==NULL && rear==NULL){
front=rear=temp;
return ;
}
temp->next=rear;
rear=temp;
}
void delete(){
struct Node*temp =front;
if(front==NULL) return;
if(front==rear){
front=rear=NULL;
}
else{
front=front->next;
}
free(temp);
}
void print(){
struct Node*temp=front;
printf("list is : ");
while(temp!=NULL){
printf("%d",temp->data);
temp=temp->next;
}
printf("\n");
}
int main(){
Insert(2);
Insert(3);
Insert(9);
Insert(6);
print();
delete();
delete();
print();
}Editor is loading...