Gate2019 cs Q28

0. Consider the following C program:

 int jumble(int x, int y){
 x=2*x+y;
 return x;
 }
 int main(){
 int x=2, y=5;
  y=jumble(y,x);
  x=jumble(y,x);
  printf(“%d \n”, x);
  return 0;
  }
  The value printed by the program is _______.

Note – Numerical Type question

  • Option : A
  • Explanation :
    Given, “for” loop will run from i=0 to 4.
    i = 0
    sum = 0+ 10 – 10 = 0
    i = 1
    sum = 0 + 9 – 8 = 1
    i = 2
    sum = 1 + 8 – 6 = 3
    i = 3
    sum = 3 + 7 – 4 = 6
    i = 4
    sum = 6 + 6 – 2 = 10
    Now, loop terminate and value of sum (i.e., 10) will be printed.
    So, The output of above C program is 10.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *