728x90 AdSpace

Latest Article



Linklist Code with Pointer C C++ Example Assignment





#include<iostream.h>
#include<conio.h>
#include<ctype.h>
struct node
{int mrk;
node *next;
} ;
class linklist
{ private:
    node *first,*curr,*prev;
 public:
 void creatnode(void);
 void disp(void);
 };
void linklist::creatnode()
   { curr =new node;
   curr->next=NULL;
   cout<<"ENTER YOUR MARKS            :";
   cin>>curr->mrk;
   first=prev=curr;
   cout<<"\nDO YOU WANT TO CREATE LIST (Y/N):";
   char ch;
   ch=getche();
   while(toupper(ch)=='Y')
   {curr=new node;
   curr->next=NULL;
   cout<<"\nENTER YOUR MARKS            :";
   cin>>curr->mrk;
   prev->next=curr;
   prev=curr;
   cout<<endl<<"DO YOU WANT TO CONTINUE (Y/N) :";
   ch=getche();
   }
   }
void linklist::disp()
   { int i=0;
   curr=first;
   while(curr->next!=NULL)
   { i++;
    cout<<endl<<"NODE NUMBER :"<<i<<":"<<curr->mrk;
    curr=curr->next;
   }
   }
void main()
{linklist llist;
clrscr();
llist.creatnode();
llist.disp();
getch();
}



no image
  • Title : Linklist Code with Pointer C C++ Example Assignment
  • Posted by :
  • Date : 04:03
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment