Ascending And Descending Order

in Hindi - Ascending And Descending Order



not yet

Source Code :

RUN#include <iostream>
using namespace std;
int main(){

int num, arr[10], i, j, temp;

cout<<"Enter size of array : \n";
cin>>num;

cout<<"Enter "<<num<<" element\n";
for(i=0; i<num; i++){
cin>>arr[i];
}

for(i=0; i<num-1; i++){
for(j=i+1; j<num; j++){
if(arr[i] > arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
cout<<"Ascending Sorting :\n";
for(i=0; i<num; i++){
cout<<arr[i]<<endl;
}

for(i=0; i<num-1; i++){
for(j=i+1; j<num; j++){
if(arr[i] < arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
cout<<"Descending Sorting :\n";
for(i=0; i<num; i++){
cout<<arr[i]<<endl;
}

return 0;
}