QUIZ ON : PROGRAMMING AND PROBLEM SOLVING THROUGH PYTHON - FUNCTIONS

FUNCTIONS

00:00:00

A ‘C’ function can contain many return statements.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

A ‘C’ function can contain many return statements.

Question No# : 01 out of 20

Recursion works faster than loops.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :
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.

Recursion works faster than loops.

Question No# : 02 out of 20

Recursion cannot call a function itself.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

Recursion cannot call a function itself.

Question No# : 03 out of 20

The value obtained in the function is given back to main by using ________ keyword?

Option A. return
Option B. static
Option C. new
Option D. volatile
True Answer A

Explanation :

The value obtained in the function is given back to main by using ________ keyword?

Question No# : 04 out of 20



Functions can be called only by value

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :
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.

Functions can be called only by value

Question No# : 05 out of 20

void (*ptr)() is a pointer to a function which receives nothing and returns nothing.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

void (*ptr)() is a pointer to a function which receives nothing and returns nothing.

Question No# : 06 out of 20

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

Option A. switch
Option B. goto
Option C. go back
Option D. return
True Answer D

Explanation :

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

Question No# : 07 out of 20

Names of functions in two different files linked together can be same

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

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

Names of functions in two different files linked together can be same

Question No# : 08 out of 20

Function putchar() displays

Option A. one word at a time on the screen
Option B. one character at a time
Option C. result on the screen
Option D. None of the above
True Answer B

Explanation :

Function putchar() displays

Question No# : 09 out of 20

Functions may have several declarations, but only one definition.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :
Yes, you can have multiple declarations (or prototypes), but you can only have one function definition for a given function name in C, or function name + arguments in C++. This needs to be supported for the very frequent situation where a function has prototypes in several include files but only one definition.

Functions may have several declarations, but only one definition.

Question No# : 10 out of 20

Which of the following function declaration need not have a return statement in its body?

Option A. int a(char *s)
Option B. void b(int a[], int n)
Option C. float *c()
Option D. short d(long x)
True Answer B

Explanation :

Which of the following function declaration need not have a return statement in its body?

Question No# : 11 out of 20

An array can be passed to a function by

Option A. Call by reference
Option B. Call by value
Option C. Call by reference by passing base address to a function
Option D. Both A and C
True Answer D

Explanation :

An array can be passed to a function by

Question No# : 12 out of 20



A function cannot be defined inside another function

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :
A function cannot be defined inside the another function, but a function can be called inside a another function.

A function cannot be defined inside another function

Question No# : 13 out of 20

In C functions the actual expressions / parameters are passed on to formal parameters using the method of call by value result

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

In C functions the actual expressions / parameters are passed on to formal parameters using the method of call by value result

Question No# : 14 out of 20

In a function two return statements should never occur.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

In a function two return statements should never occur.

Question No# : 15 out of 20

If a function contains two return statements successively, the compiler will generate warnings.?

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :
Yes. If a function contains two return statements successively, the compiler will generate "Unreachable code" warnings.

If a function contains two return statements successively, the compiler will generate warnings.?

Question No# : 16 out of 20

Changes made to an array inside a function are automatically reflected in calling program.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Changes made to an array inside a function are automatically reflected in calling program.

Question No# : 17 out of 20

In the absence of a exit condition in a recursive function, the following error is given

Option A. Compile time error
Option B. Run time error
Option C. Logical error
Option D. No error
True Answer B

Explanation :
When a recursive function is called in the absence of an exit condition, it results in an infinite loop due to which the stack keeps getting filled(stack overflow). This results in a run time error.

In the absence of a exit condition in a recursive function, the following error is given

Question No# : 18 out of 20



Functions can be called either by value or by reference.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Functions can be called either by value or by reference.

Question No# : 19 out of 20

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

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

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

Question No# : 20 out of 20