forked from jrabhishek/opps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
61 lines (51 loc) · 1.1 KB
/
Copy path2.cpp
File metadata and controls
61 lines (51 loc) · 1.1 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
#include<iostream>
using namespace std;
struct employee
{
char name[100];
int id;
int salary;
char date[20];
};
int main()
{
int n =3;
//char c[10];
employee emp[n],temp;
int i,j;
cout << "enter employee detal\n";
for ( i = 0; i < n; ++i)
{
cout <<"enter id, name , date of birth and salary\n";
cin >>emp[i].id;
//cin.getline(emp[i].name,100);
cin >> emp[i].name;
cin>> emp[i].date;
//cin.getline(emp[i].date,20);
//cin.getline(c,10);
cin >> emp[i].salary;
}
for ( i = 0; i < n-1; ++i)
{
for (j = i+1; j < n; ++j)
{
/* code */
if(emp[i].salary>emp[j].salary)
{
temp = emp[i];
emp[i] = emp[j];
emp[j] = temp;
}
}
}
cout << "======================================================\n";
cout << "\tid\tname\tdob\tsalary\t\n";
cout << "======================================================\n";
for ( i = 0; i < n; ++i)
{
cout <<"\t"<<emp[i].id<<"\t"<<emp[i].name<<"\t"<<emp[i].date<<"\t"<<emp[i].salary<<"\t\n";
}
cout <<"heighest salary\n";
cout <<"\t"<<emp[n].id<<"\t"<<emp[n].name<<"\t"<<emp[n].date<<"\t"<<emp[n].salary<<"\t\n";
return 0;
}