include iostream using namespace std struct employee char name 40 char

 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
#include <iostream>
using namespace std;
struct employee {
char name[40];
char surname[40];
int age;
};
int main() {
size_t dimension;
printf("Enter the dimension of employees array: ");
cin >> dimension;
struct employee employees[dimension];
string query;
for (int i = 0; i < dimension; ++i) {
cout << "Enter name" << endl;
cin >> employees[i].name;
cout << "Enter surname" << endl;
cin >> employees[i].surname;
cout << "Enter age" << endl;
cin >> employees[i].age;
}
cout << "Entered array:" << endl;
for (int i = 0; i < dimension; ++i) {
cout << i << " - " << employees[i].name << " - " << employees[i].surname << " - " << employees[i].age << endl;
}
cout << "Enter the name of the employee you want to search." << endl;
cin >> query;
for (int i = 0; i < dimension; ++i) {
if (employees[i].name == query) {
cout << "Employee named " << query << " found." << endl;
cout << "Name: " << employees[i].name << endl << "Surname: " << employees[i].surname << endl << "Age: " << employees[i].age << endl;
break;
}
}
return 0;
}