362 views

1 Answer

1 votes
1 votes
Ans is 111 ( option B)

x is declared globally and initiliase to 10.  Hence we can access it anywhere outside main as well as inside main

first from main you called function1(10)

void function1(int x){

  x = x * x;         //  It's x is not same as we declared globally , it's another variable, which can be access inside this function only

  function2(x);    // function2(100)

}

void function2(int y){

x = x + y;                       //  Here, x is our global variable, hence it will add  100  to it  and make x to 110

}

int main(){

        function1(x);                here on calling this function will change x to 110 finally.

        x++;                            // Incremenet x by 1

cout << x << endl;                //  print 111.

}

Related questions

1 votes
1 votes
1 answer
2
1 votes
1 votes
2 answers
3
ramakrushna asked Dec 26, 2021
541 views
I know the answer but need a good explanation for this question. Can anyone help. Thanks!
0 votes
0 votes
1 answer
4
shubhamdarokar asked Jan 19, 2017
508 views