Code:#include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; int main() { typedef struct list { int info; struct list *link; }node; int a; char res; node *start,*ptr,*ptr1,*ne,*ne1; do{ cout<<"Enter 1 to create the list, 2 to insert in the begining, 3 to insert at the end, 4 to insert at a particular location"; cin>>a; switch(a) { case 1: cout<<"Enter the number of nodes in the linked list"<<endl; int n; cin>>n; ptr=(node*)malloc(sizeof(node)); start=ptr; cout<<"Enter the info"; cin>>start->info; ptr1=start; for(int i=1;i<=(n-1);i++){ ptr=(node*)malloc(sizeof(node)); ptr1->link=ptr; cout<<"Enter the info"; cin>>ptr->info; ptr->link=NULL; ptr1=ptr; } ptr=start; while(ptr!=NULL) { cout<<ptr->info <<" --> "; ptr=ptr->link; } cout<<"NULL"<<endl; cout<<"Do You Want to repeat?"; cin>>res; break; case 2: ne=(node*)malloc(sizeof(node)); ne->link=start; start=ne; cout<<"Enter the info"; cin>>ne->info; ptr=start; while(ptr!=NULL) { cout<<ptr->info <<" --> "; ptr=ptr->link; } cout<<"NULL"<<endl; cout<<"Do You Want to repeat?"<<endl; cin>>res; break; case 3: ne=(node*)malloc(sizeof(node)); int p=1; ptr=start; while(p!=(n)) { ptr=ptr->link; p++; } ptr->link=ne; ne->link=NULL; cout<<"Enter the info"; cin>>ne->info; ptr=start; while(ptr!=NULL) { cout<<ptr->info <<" --> "; ptr=ptr->link; } cout<<"NULL"<<endl; cout<<"Do You Want to repeat?"<<endl; cin>>res; break; case 4 : int pos; cout<<"Enter the position"; cin>>pos; ne1=(node*)malloc(sizeof(node)); int f=1; ptr=start; while(f!=(pos)) { ptr=ptr->link; f++; } ne1->link=ptr->link; ptr->link=ne1; ptr=start; while(ptr!=NULL) { cout<<ptr->info <<" --> "; ptr=ptr->link; } cout<<"NULL"<<endl; cout<<"Do You Want to repeat?"<<endl; cin>>res; break; } }while(res=='y'); getch(); return 0; }
D:\Programming\link_new.cpp In function 'int main()':
90 7 D:\Programming\link_new.cpp [Error] jump to case label [-fpermissive]
67 7 D:\Programming\link_new.cpp [Error] crosses initialization of 'int p'