C Programming
Q91.
Consider the following C program: #include < stdio.h > int main( ) { int i, j, k = 0; j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5; k -= --j; for(i = 0; i < 5; i++) { switch(i + k) { case 1: case 2: printf("n%d", i+k); case 3: printf("n%d", i+k); default: printf("n%d", i+k); } } return 0; } The number of times printf statement is executed is ________.Q92.
Consider the following ANSI C program #include < stdio.h > int foo(int x, int y, int q) { if ((x < = 0) && (y < = 0)) return q; if (x < = 0) return foo(x, y-q, q); if (y < = 0) return foo(x-q, y, q); return foo(x, y-q, q) + foo(x-q, y, q); } int main( ) { int r = foo(15, 15, 10); printf("%d", r); return 0; } The output of the program upon execution is ____Q93.
Consider the following program: int main() { f1(); f2(2); f3(); return(0); } int f1() { return(1); } int f2(int X) { f3(); if (X==1) return f1(); else return (X*f2(X-1)); } int f3() { return(5); } Which one of the following options represents the activation tree corresponding to the main function?Q94.
The integer value printed by the ANSI-C program given below is ______.#include < stdio.h > int funcp(){ static int x = 1; x++; return x; } int main(){ int x,y; x = funcp(); y = funcp()+x; printf("%d\n", (x+y)); return 0; }Q95.
Consider the following ANSI C function: int SimpleFunction(int Y[], int n, int x) { int total = Y[0], loopIndex; for (loopIndex=1; loopIndex<=n-1; loopIndex++) total=x*total +Y[loopIndex]; return total; } Let Z be an array of 10 elements with Z[i]=1, for all i such that 0\leq i \leq 9. The value returned by SimpleFunction(Z,10,2) is __________Q96.
What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed? a=3; void n(x){x=x*a; print(x);} void m(y){a=1;a=y-a;n(a);print(a);} void main(){m(a);}Q97.
Consider thefollowingprogram: int f(int*p, int n) { if (n<=1)return0; else returnmax(f(p+1,n-1),p[0]-p[1]); } int main() { int a[]={3,5,2,6,4}; printf("%d", f(a,5)); } Note: max(x,y) returns the maxi mumof x and y. The value printed by this program is____________ .Q98.
Consider the following recursive C function that takes two arguments unsigned int rer(unsigned int n, unsigned int r){ if(n>0)return(n%r + rer(n/r,r)); else retturn 0; }What is the return value of the function rer when it is called as rer(513,2)?Q99.
Consider the following C program: 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 the function convert is called with any positive integer n as argument?Q100.
Consider the C functions foo and bar given below: int foo (int val ) { int x = 0; while (val > 0) { x = x + foo(val--); } return val ; } int bar (int val ) { int x = 0; while (val > 0) { x = x + bar(val-1);} return val ; } Invocations of foo(3) and bar(3) will result in: