-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.cpp
More file actions
51 lines (34 loc) · 856 Bytes
/
Copy pathlocation.cpp
File metadata and controls
51 lines (34 loc) · 856 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
#include <iostream>
using namespace std;
struct Student {
int stage;
int age;
};
int function(int base, int structsize, int location);
int main()
{
Student str[3];
for (int i = 0; i < 3; i++)
{
cout << "Enter Age for Student " << i + 1 << endl;
cin >> str[i].age;
cout << "Enter stage for Student " << i + 1 << endl;
cin >> str[i].stage;
}
for (int i = 0; i < 3; i++)
{
if (str[i].stage==1) {
cout << "This Students age is " << str[i].age << " and its stage is " << str[i].stage << endl;
}
}
int base = 400;
int structsize = 8;
int location;
cout << "What Location do you want??(how many struct you have)" << endl;
cin >> location;
cout << function(base, structsize, location) << endl;
}
int function(int base, int structsize,int location) {
int loc = base + (location * structsize);
return loc;
}