Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What does the following function do?int fun(int x, int y){if (y == 0) return 0;return (x + fun(x, y-1));}(A) x + y(B) x + x*y(C) x*y(D) xy

Answer»
2.

What does the following function do?int fun(unsigned int n){if (n == 0 || n == 1)return n;if (n%3 != 0)return 0;return fun(n/3);}(A) It returns 1 when n is a multiple of 3, otherwise returns 0(B) It returns 1 when n is a power of 3, otherwise returns 0(C) It returns 0 when n is a multiple of 3, otherwise returns 1(D) It returns 0 when n is a power of 3, otherwise returns 1

Answer»
3.

Output of following program?#include<stdio.h>void print(int n){if (n > 4000)return;printf("%d ", n);print(2*n);printf("%d ", n);}int main(){print(1000);getchar();return 0;}(A) 1000 2000 4000(B) 1000 2000 4000 4000 2000 1000(C) 1000 2000 4000 2000 1000(D) 1000 2000 2000 1000

Answer»
4.

What does fun2() do in general?int fun(int x, int y){if (y == 0) return 0;return (x + fun(x, y-1));}int fun2(int a, int b){if (b == 0) return 1;return fun(a, fun2(a, b-1));}(A) x*y(B) x+x*y(C) xy(D) yx

Answer»
5.

Predict output of following program#include <stdio.h>int fun(int n){if (n == 4)return n;else return 2*fun(n+1);}int main(){printf("%d ", fun(2));return 0;}(A) 4(B) 8(C) 16(D) Runtime Error

Answer» None