QUIZ ON : PROGRAMMING AND PROBLEM SOLVING THROUGH PYTHON - FUNCTIONS

FUNCTIONS

00:00:00

exit() function is defined in stdio.h header file.

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

Explanation :
The exit() function is a type of function with a return type without an argument. It's defined by the stdlib header file. You need to use ( exit(0) or exit(EXIT_SUCCESS)) or (exit(non-zero) or exit(EXIT_FAILURE) ) .

exit() function is defined in stdio.h header file.

Question No# : 01 out of 20



Which of the following is the correct order if calling functions in the below code? a = f1(23, 14) * f2(12/4) + f3();

Option A. f1, f2, f3
Option B. f3, f2, f1
Option C. Order may vary from compiler to compiler
Option D. None of the above
True Answer C

Explanation :

Which of the following is the correct order if calling functions in the below code? a = f1(23, 14) * f2(12/4) + f3();

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

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# : 04 out of 20

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# : 05 out of 20

Functions cannot return a floating point number

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

Explanation :
A function can return floating point value.

Functions cannot return a floating point number

Question No# : 06 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# : 07 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# : 08 out of 20

A function name can be passed as an argument to another function.

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

Explanation :

A function name can be passed as an argument to another function.

Question No# : 09 out of 20

Maximum number of arguments that a function can take is 12

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

Explanation :
C can accept upto 127 maximum number of arguments in a function.

Maximum number of arguments that a function can take is 12

Question No# : 10 out of 20

exit() function is defined in stdio.h header file.

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

Explanation :

exit() function is defined in stdio.h header file.

Question No# : 11 out of 20



The address of the variable is passed to a function in call by reference.

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

Explanation :

The address of the variable is passed to a function in call by reference.

Question No# : 12 out of 20

Every function in ‘C’ must have a “return” statement.

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

Explanation :

Every function in ‘C’ must have a “return” statement.

Question No# : 13 out of 20

In C all functions except main() can be called recursively.

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

Explanation :
Any function including main() can be called recursively.

In C all functions except main() can be called recursively.

Question No# : 14 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# : 15 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# : 16 out of 20

Functions can return a floating point number.

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

Explanation :
Yes, you can use float as a return type in C. Yes you can use, write prototype before calling that function otherwise compiler will assume it has a int and returns the int value.

Functions can return a floating point number.

Question No# : 17 out of 20

Functions cannot return more than one value at a time

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

Explanation :
The default return type for a function is int.

Functions cannot return more than one value at a time

Question No# : 18 out of 20

For the function

int operation (int A[], int n)
{
}
Which is the appropriate calling statement from main program?

Option A. s=operation(A[], 6)
Option B. operation(A, 6)
Option C. k=operation(A, 6)
Option D. d=operation(int A, 6)
True Answer C

Explanation :

For the function

int operation (int A[], int n)
{
}
Which is the appropriate calling statement from main program?

Question No# : 19 out of 20



getchar() function is available in which header file?

Option A. Stdio.h
Option B. Conio.h
Option C. Math.h
Option D. Header.h
True Answer A

Explanation :

getchar() function is available in which header file?

Question No# : 20 out of 20