JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
about 2 hours ago1 views
👨‍💻Programming

Untitled Page

#include<stdio.h>
struct node{
	int data;
	struct node *next;
	
};
struct node *start=NULL;
struct node * createnode(){
	struct node *n;
	n=(struct node *)malloc(sizeof(struct node));
	return n;
}

insertnode(){
	struct node *temp;
		struct node *k;
	temp=createnode();
	printf("enter a no");
	scanf("%d",&temp->data);
	temp->next=NULL;
	
	if(start==NULL){
		start=temp;
	}
	else{
		k=start;
		while(k->next!=NULL){
			k=k->next;
		}
		k->next=temp;
	}
	
}
show(){
	struct node *t;
	if(start==NULL){
		printf("list khali hai\t");
	}
	else{
	
	   t=start;
	  while(t!=NULL){
	  	printf("%d\t",t->data);
	  	t=t->next;
	  }
    }
}
del(){
	struct node *del;
	if(start==NULL){
		printf("empty");
		
	}
	else{
		del=start;
		start=start->next;
		free(del);
		printf("element deleted successfully\n");
	}
	
}
main(){
	int ch;
	while(1){
	printf("\npress 1 for insertion\n press 2 for display \n press 3 for deletion\n ");
	scanf("%d",&ch);
switch(ch){

	case 1:
		insertnode();
		break;
	case 2:
		show();
		break;
	case 3:
		del();
		break;
    }        
  }
}
← Back to timeline