New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Program to short the array using the bubble sort in c


Posted Date:     Total Responses: 0    Posted By: R.K. GURU   Member Level: Silver   Points/Cash: 5   


//Developed by R.K.Gour

#include
#include
#include
void bubble_sorti(int[],int); //function prototype
void bubble_sortd(int[],int); //function prototype
void main()
{
int a[20],i,n,index,ch;
char b;
clrscr();
a:
cout<<"\n\n\t\t****MENU****";
cout<<"\n1.TO SORT THE ARRAY IN ASCENDING ORDER";
cout<<"\n2.TO SORT THE ARRAY IN DESCENDING ORDER";
cout<<"\n3.EXIT";
cout<<"\n\nENTER YOUR CHOICE ";
cin>>ch;
switch(ch)
{
case 1:cout<<"\n\nENTER THE NUMBER OF ELEMENTS (MAXIMUM 20)::";
cin>>n;
cout<<"\nENTER THE ARRAY ELEMENTS \n";
for(i=0;i {
cin>>a[i];
}
bubble_sorti(a,n); //function calling
cout<<"\n\nTHE SORTED ARRAY IS SHOWN AS:: ";
for(i=0;i {
cout< }
break;
case 2:cout<<"\n\nENTER THE NUMBER OF ELEMENTS (MAXIMUM 20)::";
cin>>n;
cout<<"\nENTER THE ARRAY ELEMENTS \n";
for(i=0;i {
cin>>a[i];
}

bubble_sortd(a,n);
cout<<"\n\nTHE SORTED ARRAY IS SHOWN AS:: ";
for(i=0;i {
cout< }
break;
case 3:exit(0);
break;
default :cout<<"\nWRONG CHOICE";
cout<<"\nDO YOU WANT TO CONTINUE, ENTER (Y/N):";
cin>>b;
if(b=='y'||b=='Y')
goto a;
break;
}
getch();
}
//***************************************************************
void bubble_sorti(int a[],int size) //function definition
{
getch();
clrscr();
int temp,ctr=0;
for(int i=0;i {
for(int j=0;j<(size-1)-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\nTHE ARRAY AFTER THE ITERATION :"<<++ctr<<" IS ::";
for(int k=0;k {
cout< }
}
}
}
void bubble_sortd(int a[],int size) //function definition
{
getch();
clrscr();
int temp,ctr=0;
for(int i=0;i {
for(int j=0;j<(size-1)-i;j++)
{
if(a[j] {
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\nTHE ARRAY AFTER THE ITERATION :"<<++ctr<<" IS ::";
for(int k=0;k {
cout< }
}
}
}

//**************************************************************************



















Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: Screen Programming Project - SAP
Previous Project: Using System Fields along with Case Statements

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.