The variable in the function declaration and definition can vary because
when a function is declared the compiler is informed that a function with
the particular name and with the number of parameter will be used(defined)
later in the code.
These are only dummy variables and that doesn't accounts when we change the
variable names during the definition.

On Tue, Aug 23, 2011 at 11:00 PM, rajesh krishnan <
[email protected]> wrote:

> the answer is A
> Because the first function called is using call by value
> The second function is called using call by reference.
>
>
> On Sun, Aug 21, 2011 at 5:21 PM, mandy <[email protected]> wrote:
>
>> #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.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
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.

Reply via email to