//Main function
int main()
{
	int choice,n;
	while(1)
	{
		printf("\n1. Insert at beginning\n2. Insert at End\n3. Delete from beginning\n4. Delete from End\n5. Display total\n6. Count elements\n7. Exit");
		printf("\nEnter your choice ");
		scanf("%d",&choice);
		switch(choice)
		{
		case 1 : printf("Enter data : ");
        		scanf("%d", &n);
            	insert_beg(n);
				break;
		case 2 : printf("Enter data : ");
        		scanf("%d", &n);
            	insert_end(n);
				break;
		case 3: del_beg();
				break;
		case 4: del_end();
				break;
		case 5 : display();
				break;
		case 6: link_count();
				break;
		case 7: exit(1);
		default : printf("Wrong entry please enter correct choice !!! ");
				break;
		}
	}
}
Ejemplo n.º 2
0
int main()
{
	head = NULL;
	while(1){	
		printf("1.INSERT : \n2.DELETE : \n3.SEARCH : \n4.DISPLAY : \n");
		int ch;
		scanf("%d",&ch);
		if (ch==1)
		{
			int roll;
			char name[100];
			float cgpa;
			printf("Enter ROLL NO. to be inserted\n");
			scanf("%d",&roll);
			printf("Enter NAME to be inserted\n");
			gets(name);
			printf("Enter CGPA to be inerted\n");
			scanf("%f",&cgpa);
			insert(roll,name,cgpa);
		}
		else if(ch==2){
			int ch1;
			printf("1.DELETE at BEGINNING: \n2.DELETE at END: \n3.DELETE at BETWEEN:\n");
			scanf("%d",&ch1);
			if(ch1==1){
				del_beg();
			}
			else if(ch1==2){
				del_end();
			}
			else if(ch1==3){
				printf("Enter the POSITION at which node is to be DELETED\n");
				int k;
				del_btw(scanf("%d",&k));		
			}
			else printf("INVALID INPUT");

		}
		else if(ch==3){
			int roll;
			printf("Enter ROLL NO. to be searched\n");
			scanf("%d",&roll);
			search(roll);
		}
		else if(ch==4)DISPLAY();
		else {printf("INVALID INPUT\n");break;}
	}
	return 0;
}
//Main Execution
void main()
{
	int a,i;
	clrscr();
	while(1)
	{
		printf("\n1.insert_beg\n");
		printf("2.insert_end\n");
		printf("3.display\n");
		printf("4.del_beg\n");
		printf("5.del_end\n");
		printf("6.del_after\n");
		printf("7.insert_befroe\n");
		printf("8.exit\n");
		printf("\n");
		printf("enter a choice:");
		scanf("%d",&a);
		switch(a)
		{
			case 1:insert_beg();
						break;
			case 2:insert_end();
						break;
			case 3:display();
						break;
			case 4:del_beg();
						break;
			case 5:del_end();
						break;
			case 6:del_after();
						break;
			case 7:insert_before();
						break;
			case 8:
						exit(1);
			default:
						printf("enter a valid choice");
		}
	}
}