Answer to Question #20249 in C++ for haseeb

Question #20249
write a program to declare an array ,input values from user and solved them in ascending order
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS