Functions


Q11.

In the following procedure Integer procedure P(X,Y); Integer X,Y; value x; begin K=5; L=8; P=x+y; endX is called by value and Y is called by name. If the procedure were invoked by the following program fragment K=0; L=0; Z=P(K,L);then the value of Z will be set equal to
GateOverflow

Q12.

The output of executing the following C program is ________. # include int total (int v) { while (v) { static int count + = v & 1; v>> = 1; } return count; } void main ( ) { static int x = 0; int i = 5; for (; i> 0; i--) { x=x + total (i) ; } printf ("%d\n", x) ; }
GateOverflow

Q13.

Consider the following two functions. The output printed when fun1(5) is called is
GateOverflow

Q14.

The value printed by the following program is . void f(int*p, int m){ m =m+5; *p =*p+m; return; } void main(){ int i=5, j=10; f(&i, j); printf("%d", i+j); }
GateOverflow

Q15.

Consider the following C code segment int f(int x) { if(x<1) return 1; else return (f(x-1) + g(x)); } int g(int x) { if(x<2) return 2; else return (f(x-1) + g(x/2)); }Of the following, which best describes the growth of f(x) as a function of x ?
GateOverflow

Q16.

Which one of the following is correct about the statements given below? I. All function calls are resolved at compile time in C lang II. All function calls are resolved at compile time in C++ lang
GateOverflow

Q17.

Consider the following C program: #include < stdio.h > void fun1(char *s1, char *s2){ char *tmp; tmp = s1; s1 = s2; s2 = tmp; } void fun2(char **s1, char **s2){ char *tmp; tmp = *s1; *s1 = *s2; *s2 = tmp; } int main(){ char *str1 = "Hi", *str2 = "Bye"; fun1(str1, str2); printf("%s %s ", str1, str2); fun2(&str1, &str2); printf("%s %s", str1, str2); return 0; } The output of the program above is
GateOverflow

Q18.

Consider the following C program: #include < stdio.h > int counter = 0; int calc (int a, int b) { int c; counter++; if (b==3) return (a*a*a); else { c = calc(a, b/3); return (c*c*c); } } int main (){ calc(4, 81); printf ("%d", counter); } The output of this program is _____.
GateOverflow

Q19.

What is the output of the following program? #include < stdio.h > int tmp=20; main() { printf("%d", tmp); func(); printf("%d", tmp); } func() { static int tmp=10; printf("%d", tmp); }
GateOverflow

Q20.

Consider the following ANSI C function:int SomeFunction (int x, int y) { if ((x==1) || (y==1)) return 1; if (x==y) return x; if (x > y) return SomeFunction(x-y, y); if (y > x) return SomeFunction (x, y-x); } The value returned by SomeFunction(15, 255) is __________
GateOverflow