c++ program to sort predefined numbers

#include<iostream>
using namespace std;
//int sort_given_num(int arr[]);
int main()
{
int i,j,temp;
int arr[8]={12,10,14,18,2,20,7,30};
for(i=0;i<8;i++)
{
for(j=1;j<8;j++)
if(arr[j]<arr[i]);
{
temp=arr[i];
arr[j]=arr[i];
arr[i]=temp;
}

}
for(i=0;i<8;i++)

cout<<arr[i]<<endl;

}
OUT:
12
10
14
18
2
20
7
30

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat