info@tutorialdiary.com

Saturday, May 21, 2016

Common Output Question in AMCAT | Value of a and b

2:44 AM

Share it Please
Q:
function modify(w,u)
{
w = w + 2 u = u - 3
return (w - u)
}
function calculate( )
{
integer a = 10, b = 20, c c = modify(a, b);
print a print space print b
}
Assume that a was passed by value and b was passed by reference. What will be the output of the program on executing function calculate( ) ?
a) 12 17
b) 10 17
c) 12 20
d) 10 20


Answer is (d




Run the following program in your c compiler, you will get your answer:

#include <stdio.h>

int modify(w,u)
{
w = w + 2;
u = u - 3;
return (w - u);
}



void calculate( )
{
int a = 10, b = 20, c;
c = modify(a, b);
printf("%d %d", a, b);
}

int main () {

calculate();
return 0;
}

0 comments:

Post a Comment