64 736
Assignments Done
99,3%
Successfully Done
In September 2018

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
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions