In: Computer Science
1)What is the output of the following code?
struct someType
{ int a;
int b;
};
void f1(someType &s)
{ s.a = 1;
s.b = 2;
}
someType f2(someType s)
{ someType t;
t = s;
s.a = 3;
return t;
}
int main()
{ someType s1, s2;
f1(s1);
s2 = f2(s1);
cout << s1.a << '-' << s1.b << '-'
<<
s2.a << '-' << s2.b << '-' << endl;
return 0;
}
------------------------------------------------------------------------------------------------------------------
2)
struct dateType { int month; int day; int year; }; struct employeeType { string name; dateType birthDate; dateType hireDate; }; employeeType emp; cout << emp.name << endl; cout << " Born " << emp.birthDate.month << "-" << emp.birthDate.day << endl;
QUestion --The following code is used to read in the year each employee was hired. What should be placed in the blank to finish the code?
// Use structures declared above
employeeType employees[10];
for (int i = 0; i < 10; i++)
{
cin >> ___________;
}
Question 1:
Answer :1-2-1-2-
Explanation :
Below screen shows the output
========================
Question 2:
Screen :
Explanation :Here emp.name will be empty and emp.birthDate.month will be 0 and emp.birthDate.day will be 0
======================
Question 3:
employeeType employees[10];
for (int i = 0; i < 10; i++)
{
cin>>employees[i].hireDate.year;
}