-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment 13.cpp
More file actions
52 lines (50 loc) · 1.04 KB
/
Assignment 13.cpp
File metadata and controls
52 lines (50 loc) · 1.04 KB
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
//============================================================================
// Name : Assignment.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int d[10];
int e,n;
char c;
cout<<"Enter your list:"<<endl;
for(int i=0;i<10;i++)
cin>>d[i];
cout<<"Your list is :"<<endl;
for(int i=0;i<10;i++)
cout<<d[i]<<" ";
cout<<endl;
do
{
cout<<"Enter your choice: \n1.Search\n2.Sort\n";
cin>>e;
switch(e)
{
case 1:
cout<<"Enter element to be searched for: ";
cin>>n;
if(binary_search(d,d+10,n))
cout<<"Element is present!"<<endl;
else
cout<<"Element is absent!"<<endl;
break;
case 2:
sort(d,d+10);
for(int i=0;i<10;i++)
cout<<d[i]<<" ";
break;
default:
cout<<"Invalid option";
}
cout<<"Continue?";
cin>>c;
}
while(c=='Y'||c=='y');
cout<<"Exit";
return 0;
}