Computer Science, asked by rajasekhar171, 1 year ago

Write a c++ program to sort an array of integer in ascending order using a function called exchange( ) which accepts two integer arguments.

Answers

Answered by Anonymous
34
Answer
..............



#include<iostream.h>

#include<conio.h>



void main() { int i,a[10],temp,j;



clrscr(); cout<<"Enter any 10 num in array:

\. n"; for(i=0;i<=10;i++) { cin>>a[i]; } cout<<"\nData before sorting: ";


for(j=0;j<10;j++) { cout<<a[j]; } for(i=0;i<=10;i++)



{ for(j=0;j<=10-i;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; }




}


}




cout<<"\nData after sorting



: "; for(j=0;j<10;j++)



{




cout<<a[j]; } getch();


}
Similar questions