-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment 8.cpp
More file actions
62 lines (60 loc) · 1.11 KB
/
Assignment 8.cpp
File metadata and controls
62 lines (60 loc) · 1.11 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
53
54
55
56
57
58
59
60
61
62
//============================================================================
// Name : assignment.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
template<class s>
s sort(s a[])
{
int i,j,n;
s temp;
cout<<"Enter the number of elements: "<<endl;
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"Enter the "<<i<<"th element: "<<endl;
cin>>a[i];
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
cout<<"Sorted:";
for(i=1;i<=n;i++)
{
cout<<a[i]<<endl;
}
}
int main()
{
int a1[100],ch;
string s;
float a2[100];
do{
cout<<"Enter the choice:\n1)Integer array sorting:\n2)Float array sorting:<<endl";
cin>>ch;
switch(ch)
{
case 1:sort(a1);
break;
case 2:sort(a2);
break;
default:cout<<"you entered wrong choice";
}
cout<<"Do you want to continue,press y:"<<endl;
cin>>s;
}while(s=="y");
return 0;
}