|
Technical Interview Questions
Visual Basic Interview Question
ASP .NET Interview Questions
C++ Interview Questions
C
Interview Questions
.........More
Programming Source Codes
C/C++ Source Codes
C# Source Codes
.........More
Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
.........More
Tutorials
C Tutorial
C++ Tutorial
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
C/C++ Source Codes
programme for sorted linked
list...(not only linked list MARK sorted.)
#include<iostream.h>
#include<process.h>
class link
{
link* next;
int data,no;
public :
link* sort(link*);
void traverse(link*);
//link* dele (link*);
};
link * link::sort(link* temp)
{
link* newlink;
link* dummy1;
newlink=new link;
cout<<"\nEnter Data (only positive number) :";
cin>>no;
dummy1 = temp;
if (temp==NULL '' dummy1->data > no)
{
newlink->data = no;
newlink->next=temp;
temp=newlink;
return temp;
}
else
{
link *cur;
link *dummy;
cur=temp;
dummy = cur->next ;
while(cur->next!=NULL)
{
if(dummy->data > no)
{
newlink->next = cur->next;
newlink->data = no;
cur->next = newlink;
return temp;
}
dummy=dummy->next ;
cur=cur->next;
}
newlink->data = no;
newlink->next=NULL;
cur->next=newlink;
}
return temp;
}
void link::traverse(link *temp)
{
while(temp!=NULL)
{
cout<<temp->data<<endl;
temp=temp->next;
}
}
void main()
{
link *first=NULL,l1;
int choice;
while(1)
{
cout<<"\n*************** SORTED LINK LIST (For Integer Only)
***************\n\n";
cout<<"Choices Are :-\n=> [1] For Insert \n=> [2] For Traverse \n=> [3] For
Exit";
cout<<"\n\nEnter Your choice : ";
cin>>choice;
switch (choice)
{
case 1:
first=l1.sort(first);
break;
case 2:
l1.traverse(first);
break;
case 3:
exit(0);
}
}
}
<<<----- Return to
C/C++ Source Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Object Oriented Interview
Questions for more Object Oriented Interview Questions with answers
Check
Data Structure
Interview Questions for more data structure interview questions with
answers
|