+0  
 
0
592
1
avatar

Write a program in c++ which inputs three numbers and outputs the message Sorted if the numbers are in ascending order, and outputs Not sorted otherwise.

 

plz i want solve this and thanks :)

 Nov 3, 2016
 #1
avatar
0

hi :)

this is solve!! :D

 

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


int numbers[3]; 
bool ascending = true; 
for (int i = 0;i < 3;i++) { 
cout<< "Number "<< (i + 1) << ": "; 
cin >> numbers[i]; 

for (int i = 1;i < 3;i++) 
if (numbers[i] < numbers[i - 1]) 
ascending = false; 
if (ascending == true) 
cout<< "Sorted." <<endl; 
else 
cout<< "Unsorted." <<endl; 
return 0; 

}

 Nov 4, 2016

3 Online Users

avatar