recategorized by
16,689 views
35 35 votes

Consider the following C program :

#include<stdio.h>
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 ______________.

5 Answers

Best answer
51 51 votes
$x = 2, y = 5$

$y =$ jumble$(5,2)$ //call by value and $y$ will hold return value. After this call $x = 2, \: y = 12$

$x =$ jumble$(12, 2)$ //call by value and $x$ will hold return value. After this call $x = 26, \: y = 12$

$x=26$
edited by
3 3 votes

jumble function is just taking 2 arguments say arg1 and arg2. and returning (2*arg1) + arg2

in main function we have below:

y=jumble(5,2);---main called jumble function with arguments 5,2 initially  and result was stored in variable y

here y becomes 12  i.e: (2*10)+2

x remains same which is 2

x=jumble(12, 2);----main again called jumble function with arguments 12,2  and stored in variable x

so x becomes 26   i.e: (2*12)+2

finally x will be printed
output: 26

 

1 1 vote
1st jumble will return 12 that will be stored in y.

this y will be passed as parameter in 2nd jumble that will return 26 in x.
Answer:
Position:
Show:

Related questions

40 40 votes
11 answers 11 answers
27.5k
27.5k views
Arjun asked Feb 7, 2019
27,497 views
Consider the following C function.void convert (int n ) { if (n<0) printf{“%d”, n); else { convert(n/2); printf(“%d”, n%2); } }Which one of the following will happen when...
36 36 votes
10 answers 10 answers
23.4k
23.4k views
Arjun asked Feb 7, 2019
23,390 views
Consider the following C program:#include <stdio.h int main() { int arr[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5}, *ip=arr+4; printf(“%d\n”, ip ); return 0; }The number t...
40 40 votes
6 answers 6 answers
25.4k
25.4k views
Arjun asked Feb 7, 2019
25,370 views
Consider the following C program:#include <stdio.h int main() { float sum = 0.0, j=1.0, i=2.0; while (i/j 0.0625) { j=j+j; sum=sum+i/j; printf("%f\n", sum); } return 0; ...
43 43 votes
2 answers 2 answers
23.2k
23.2k views
Arjun asked Feb 7, 2019
23,246 views
Consider the following C program:#include <stdio.h int main() { int a[] = {2, 4, 6, 8, 10}; int i, sum=0, *b=a+4; for (i=0; i<5; i++) sum=sum+(*b-i)-*(b-i); printf("%d\n"...