-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4th.cpp
More file actions
37 lines (36 loc) · 632 Bytes
/
Copy path4th.cpp
File metadata and controls
37 lines (36 loc) · 632 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//check if array is sorted or not
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cout<<"Enter numeber of elements in an array :\n";
cin>>n;
int arr[n];
cout<<"Enter elements in the array :"<<endl;
for(int i=0;i<n;i++)
{
cout<<": ";
cin>>arr[i];
}
int flag=1;
if(n==1)
cout<<"Sorted\n";
else
{
for(int i=0;i<n-1;i++)
{
if(arr[i+1]<arr[i])
{
flag=0;
break;
}
}
}
if(!flag)
{
cout<<"Not-Sorted\n";
}
else
cout<<"Sorted\n";
}