-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23.cpp
More file actions
52 lines (36 loc) · 821 Bytes
/
23.cpp
File metadata and controls
52 lines (36 loc) · 821 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
@Author: Amritanshu Sikdar
Session: 2018-'19
Repository: https://github.com/amritanshusikdar/CS30PracticalQuestion
*/
// Program to check whether given list is sorted or not
#include<iostream.h>
#include<conio.h>
void is_sort(int*, int);
void main()
{
clrscr();
int i,*list, size;
cout << "Enter size of list: ";
cin >> size;
list = new int[size];
for(i=0; i<size; i++)
{
cout << "Element " << i+1 << ": ";
cin >> *(list+i);
}
is_sort(list,size);
getch();
}
void is_sort(int *list, int size)
{
int i=0,flag=0;
do {
if(*(list+i) > *(list+i+1))
flag = 1;
i++;
} while (i != size-2 && flag == 0);
if(flag == 1)
cout << "List is NOT sorted!";
else cout << "List is sorted!";
}