C++ program to sort the array by keeping size of array constant using const argument.
Answers
Answered by
0
Answer:
#include<iostream>
int main(){
int arr[6] = {5,2,3,7,2,6};
int f = 0;
int b = 0;
for(int i = 1;i < 6;i++){
if(arr[i] < arr[i-1]){
f = arr[i];
b = arr[i-1];
arr[i] = b;
arr[i-1] = f;
i=1;
}
}
for(int i = 0;i < 6;i++) std::cout << arr[i] << " ";
}
Explanation:
Similar questions