Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program of link list using class pointers

Posted By: Charlie Evans     Category: C++ Programming     Views: 6867

Write a program of link list using class pointers.

Code for Program of link list using class pointers in C++ Programming

#include<iostream.h>
#include<conio.h>
class stud
{
    public:
    char name[20];
    int rno;
    class stud *next;
};

main()
{
    stud *point,*first;
    first=new(class stud);
    point=first;
    while(1)
    {
        clrscr();
        cout<<"Please enter the name:";
        cin>>point->name;
        cout<<"Please enter the rollno:";
        cin>>point->rno;
        char ans;
        while(1)
        {
            cout<<"\nDo you want to continue(y/n):";
            cin>>ans;
            if(ans=='y' || ans=='Y')
            {
                break;
            }
            elseif(ans=='n' || ans=='N')
            {
                break;
            }
            else
            {
                cout<<"Invalid input";
            }
      }
      if(ans=='y' || ans=='Y')
      {
            point->next= new(class stud);
            point=point->next;
            continue;
      }
      else
      {
            point->next=NULL;
            break;
        }
}

point=first;
while(point!=NULL)
{
    cout<<"Name is   :"<<point->name<<endl;
    cout<<"Rollno is :"<<point->rno<<endl;
    getch();
    point=point->next;
}
delete point;
delete first;
}
  
Share: 


Didn't find what you were looking for? Find more on Program of link list using class pointers Or get search suggestion and latest updates.

Charlie Evans
Charlie Evans author of Program of link list using class pointers is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!