Categories
- 4th semester (27)
- 5th semester (3)
- ADA (13)
- Assembly Level Language (12)
- BE (45)
- C Language Programming (5)
- C language (20)
- C++ Language (5)
- CCP Lab programing (3)
- Computer Programming Lab (3)
- DAA Lab Programming (13)
- Data Structure and C++ laboratory Program (6)
- Data Structure and C++ labotary Program (5)
- Design and Analysis of algorithm (14)
- First Year (5)
- MASM (12)
- Microprocessor (12)
- Microprocessor lab program (12)
- System Software & OS Laboratory (5)
- Unix program (4)
- bachelor of engineering (30)
- basic (1)
- basic mathematics (2)
- beginners (10)
- c++ program (9)
- calculations (7)
- computer science (30)
- downloadable (5)
- engineering syllabus (4)
- simple program (6)
Trend Posts
Blogger news
Author
Followers
Blog Archive
Saturday, October 26, 2013
//Courtesy : Avinash G, Computer Science Dept.,Srinivas Institute of Technology,Mangalore
----
#include<iostream.h>
#include<conio.h>
#include<process.h>
class list
{
struct node
{
int info;
struct node *next;
};
struct node *plist;
public:
list()
{
plist=NULL;
}
void insert(int);
void del();
void display();
};
void main()
{
list a;
int choice,item;
clrscr();
while(1)
{
cout<<"option are 1.insert 2.delete 3.display 4.exit\n";
cout<<"enter your choice\n";
cin>>choice;
switch(choice)
{
case 1: cout<<"enter the element to be inseted\n";
cin>>item;
a.insert(item);
break;
case 2: a.del();
break;
case 3: a.display();
break;
case 4:exit(0);
}
}
}
void list::insert(int item)
{
struct node *p;
p=new (node);
p->info=item;
p->next=plist;
plist=p;
}
void list::del()
{
struct node *t;
int item;
if(plist==NULL)
cout<<"list is empty\n";
else
{
t=plist;
item=t->info;
cout<<"item removed is "<<item<<"\n";
plist=t->next;
delete(t);
}
}
void list::display()
{
struct node *temp;
if(plist==NULL)
cout<<"list is empty\n";
else
{
cout<<"list elements are ";
for(temp=plist;temp!=NULL;temp=temp->next)
cout<<temp->info<<"\t";
cout<<endl;
}
}
Program Ends
Screen shot:
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
You are very Important to Us...
STAY TUNE...