Answer to Question #20249 in C++ for haseeb
write a program to declare an array ,input values from user and solved them in ascending order
1
2012-12-10T12:01:19-0500
C++
write a program to declare an array ,input values from user and solved them in ascending order
#include <stdio.h>
#include <iostream.h>
void bubbleSortAsscending(int *array,int length)
{
int i=0,j;
while (i<length)
{
j=0;
& while (j<i)
& {
if(array[i]<array[j])
{
int temp=array[i];
array[i]=array[j];
array[j]=temp;
}
j++;
& }
i++;
}
}
void printElements(int *array,int length)
{
int i=0;
for(i=0;i<10;i++)
& cout<<array[i]<<endl;
cout<<"\n";
}
void main()
{
int b[10];
cout<<"enter 10 integers: ";
for (int i=0;i<10;i++) cin>>b[i];
bubbleSortAsscending(b,10);
printElements(b,10);
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment