#include
using namespace std;
int main() {
int Boys = 3, Girls = 5;
void F1(int males, int females);
void F2(int &m, int &f);
F1(Boys, Girls);
cout << "\nAfter calling F1, within main()";
cout << "\n\tBoys = " << Boys; // #2
cout << "\n\tGirls = " << Girls;
F2(Boys, Girls);
cout << "\nAfter calling F2, within main()";
cout << "\n\tBoys = " << Boys; // #4
cout << "\n\tGirls = " << Girls;
}
void F1(int b, int g) {
b += 3, g += 4;
cout << "\nF1";
cout << "\n\tBoys = " << b; // #1
cout << "\n\tGirls = " << g;
}
void F2(int &b, int &g) {
b = b + 8, g = g + 5;
cout << "\nF2";
cout << "\n\tBoys = " << b; // #3
cout << "\n\tGirls = " << g;
}
Question 1: What is the output of the Boys variable on the marked lines?
A) #1: 6
#2: 3
#3: 11
#4: 11
B) #1: 6
#2: 3
#3: 11
#4: 3
C) #1: 6
#2: 6
#3: 11
#4: 11
D) It outputs nothing because it does not compile or run.
pls tell me during declaration and definition variable must be same,but here
is something different.And ans is (A). Thanks......
--
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-code/-/e4EUV44QQzIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.