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.

A function may have any number of return statements each returning different values.

Answer» True, A function may have any number of return statements each returning different values and each return statements will not occur successively.
2.

Names of functions in two different files linked together must be unique

Answer» True, If two function are declared in a same name, it gives "Error: Multiple declaration of function_name())".
3.

A function cannot be defined inside another function

Answer» A function cannot be defined inside the another function, but a function can be called inside a another function.
4.

Functions cannot return more than one value at a time

Answer» True, A function cannot return more than one value at a time. because after returning a value the control is given back to calling function.
5.

If return type for a function is not specified, it defaults to int

Answer» True, The default return type for a function is int.
6.

In C all functions except can be called recursively.

Answer» Any function including main() can be called recursively.
7.

Functions can be called either by value or reference

Answer» True, A function can be called either call by value or call by reference. Example: Call by value means c = sub(a, b); here value of a and b are passed. Call by reference means c = sub(&a, &b); here address of a and b are passed.
8.

There is a error in the below program. Which statement will you add to remove it?

Answer» The correct form of function f prototype is float f(int, float);
9.

If is 2 bytes wide.What will be the output of the program?

Answer» Since C is a machine dependent language sizeof(int) may return different values. The output for the above program will be cd in Windows (Turbo C) and gh in Linux (GCC). To understand it better, compile and execute the above program in Windows (with Turbo C compiler) and in Linux (GCC compiler).
10.

What will be the output of the program in 16 bit platform (Turbo C under DOS)?

Answer» Turbo C (Windows): The return value of the function is taken from the Accumulator _AX=1990. But it may not work as expected in GCC compiler (Linux).
11.

What will be the output of the program?

Answer» Step 1: int no=5; The variable no is declared as integer type and initialized to 5. Step 2: reverse(no); becomes reverse(5); It calls the function reverse() with '5' as parameter. The function reverse accept an integer number 5 and it returns '0'(zero) if(5 == 0) if the given number is '0'(zero) or else printf("%d,", no); it prints that number 5 and calls the function reverse(5);. The function runs infinetely because the there is a post-decrement operator is used. It will not decrease the value of 'n' before calling the reverse() function. So, it calls reverse(5) infinitely. Note: If we use pre-decrement operator like reverse(--n), then the output will be 5, 4, 3, 2, 1. Because before calling the function, it decrements the value of 'n'.
12.

Every function must return a value

Answer» No, If a function return type is declared as void it cannot return any value.
13.

If a function contains two statements successively, the compiler will generate warnings. Yes/No ?

Answer» Yes. If a function contains two return statements successively, the compiler will generate "Unreachable code" warnings. Example: #include<stdio.h> int mul(int, int); /* Function prototype */ int main() { int a = 4, b = 3, c; c = mul(a, b); printf("c = %d\n", c); return 0; } int mul(int a, int b) { return (a * b); return (a - b); /* Warning: Unreachable code */ } Output: c = 12
14.

Maximum number of arguments that a function can take is 12

Answer» No, C can accept upto 127 maximum number of arguments in a function.
15.

Usually recursion works slower than loops.

Answer» When a recursive call is made, the function/process clones itself and then process that funtion. This leads to time and space constrains. In a loop, there is no recursive call involved that saves a lot of time and space too.
16.

Is it true that too many recursive calls may result into stack overflow?

Answer» Yes, too many recursive calls may result into stack overflow. because when a function is called its return address is stored in stack. After sometime the stack memory will be filled completely. Hence stack overflow error will occur.
17.

In a function two statements should never occur.

Answer» No, In a function two return statements can occur but not successively. Example: #include <stdio.h> int mul(int, int); /* Function prototype */ int main() { int a = 0, b = 3, c; c = mul(a, b); printf("c = %d\n", c); return 0; } /* Two return statements in the mul() function */ int mul(int a, int b) { if(a == 0 || b == 0) { return 0; } else { return (a * b); } } Output: c = 0
18.

Functions cannot return a floating point number

Answer» A function can return floating point value. Example: #include <stdio.h> float sub(float, float); /* Function prototype */ int main() { float a = 4.5, b = 3.2, c; c = sub(a, b); printf("c = %f\n", c); return 0; } float sub(float a, float b) { return (a - b); } Output: c = 1.300000
19.

The keyword used to transfer control from a function back to the calling function is

Answer» The keyword return is used to transfer control from a function back to the calling function. Example: #include<stdio.h> int add(int, int); /* Function prototype */ int main() { int a = 4, b = 3, c; c = add(a, b); printf("c = %d\n", c); return 0; } int add(int a, int b) { /* returns the value and control back to main() function */ return (a+b); } Output: c = 7
20.

How many times the program will print "IndiaBIX" ?

Answer» A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing. A stack overflow occurs when too much memory is used on the call stack. Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.