Skip to main content

Posts

Showing posts from October, 2017

Single linklist program in c++(only inserting and display function)

#include<iostream> using namespace std; struct node{ int data; node *next; }; class sll{ private:          node *head,*tail; public:         sll(){         head=0;         tail=0;         }         insert(int mydata){         node *tmp=new node;         tmp->data=mydata;         tmp->next=0;          int select;         cout<<"Select one of this option\n";         cout<<"1.insert element at first position\n";         cout<<"2.insert element at Any position\n";         cout<<"3.insert element at last position\n";         cin>>select;             switch(select){         case 1:if(head==0){                     head=tmp;                     tail=tmp;                 }else{                 tmp->next=head;                 head=tmp;                 }                break;         case 2:int cont;                if(head==0 && tail==0){                  cout<&