Functions
Q11.
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);}Q12.
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____________ .Q13.
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 __________Q14.
Consider the following C program: #include < stdio.h > int r(){ int static num=7; return num--; } int main() { for(r();r();r()) { printf("%d ",r()); }; return 0; } Which one of the following values will be displayed on execution of the programs?Q15.
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++ langQ16.
Consider the following function void swap(int a, int b) { int temp; temp = a; a = b; b = temp; } In order to exchange the values of two variables x and y.Q17.
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) ; }Q18.
Consider the following C++ program int a (int m) {return ++m;} int b(int&m) {return ++m;} int{char &m} {return ++m;} void main() { int p = 0, q=0, r = 0; p += a(b(p)) ; q+= b(a(q);) r+=a(c(r)); cout << p << q << r; } Assuming the required header first are already included, the above programQ19.
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)?Q20.
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