Explore topic-wise MCQs in C.

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

1.

setjmp takes a jmp_buf type and different other type variables as input.

A. true
B. false
Answer» C.
2.

What are the contents of the register?

A. sp, fp only
B. sp only
C. fp, pc only
D. sp, fp, pc
Answer» E.
3.

What will the following C statement do?

A. save the current state of the registers into env
B. resets the registers to the values saved in env
C. provides a definition for env structure
D. accept variable(env) argument lists to be writtenView Answer
Answer» B. resets the registers to the values saved in env
4.

A less common use of setjmp.h is to create syntax similar to ____________

A. errno
B. variable arguments
C. coroutines
D. retval
Answer» D. retval
5.

The void longjmp( jmp-buf env, int val) function causes setjmp() macro to return _______ value; if val is 0.

A. zero
B. one
C. null
D. no return
Answer» C. null
6.

The header file setjmp.h is used to __________

A. set location specific information
B. control low-level calls and returns to and from functions
C. handle signals reported during a program’s execution
D. manipulate strings (character arrays)
Answer» C. handle signals reported during a program’s execution
7.

WHAT_ARE_THE_CONTENTS_OF_THE_REGISTER??$

A. sp, fp only
B. sp only
C. fp, pc only
D. sp, fp, pc
Answer» C. fp, pc only
8.

CHOOSE_THE_RIGHT_DECLARATION_OF_LONGJMP()_FUNCTION.?$

A. void longjmp(jmp_buf environment, int value)
B. void longjmp(setjmp environment, int value)
C. void longjmp(int value, jmp_buf environment)
D. void longjmp(int value, setjmp environment)
Answer» B. void longjmp(setjmp environment, int value)
9.

Which function restores the environment saved by the most recent invocation of the setjmp() macro in the same invocation of the program?

A. jmp_buf
B. longjmp
C. jmpbuf
D. long_jmp
Answer» C. jmpbuf
10.

longjmp() function is the only function defined under the header file setjmp.h?

A. true
B. false
Answer» B. false
11.

A less common use of setjmp.h is to create syntax similar to

A. errno
B. variable arguments
C. coroutines
D. retval
Answer» D. retval
12.

How many times can the macro setjmp() return?

A. one time
B. two times
C. three times
D. many times
Answer» C. three times
13.

How many times does the function longjmp() returns?

A. once
B. twice
C. thrice
D. never
Answer» E.
14.

Select the correct declaration of setjmp().

A. int setjmp(jmp_buf environment)
B. int setjmp(long_jmp environment)
C. int setjmp(jmp_buf )
D. int setjmp(long_jmp)
Answer» B. int setjmp(long_jmp environment)
15.

What is the function of the given longjump(jmp_buf buf, i)?

A. go back to place buf is pointing to and return i
B. go back to place buf is pointing to and return 0
C. uses buf to remember current position and returns 0
D. uses buf to remember current position and returns i
Answer» B. go back to place buf is pointing to and return 0
16.

A non-zero value is returned, if setjmp() returns from a longjmp() function call.

A. false
B. true
Answer» C.
17.

Which of the given statement is not true with respect to void longjmp( jmp-buf env, int val)?

A. The variable value cannot be zero
B. env is the object containing information to restore the environment at the jmp_buf’s calling point
C. This function does not return any value
D. This function restores the environment saved by the most recent call to setjmp() macro
Answer» C. This function does not return any value
18.

If setjmp() macro returns directly from the macro invocation, it______

A. returns zero
B. returns non-zero
C. produces error
D. nothing can be said
Answer» B. returns non-zero
19.

Which is the true statement with respect to the function longjmp()?

A. the function where setjmp() was called has terminated, then the results are undefined
B. the function where setjmp() was called has terminated, then the results are defined
C. the function where jmp_buf was called has terminated, then the results are undefined
D. the function where jmp_buf was called has terminated, then the results are defined
Answer» B. the function where setjmp() was called has terminated, then the results are defined
20.

Which macro saves the current environment into the variable environment for later use by the function longjmp().

A. setjmp
B. longjmp
C. jmp
D. set_jmp
Answer» B. longjmp
21.

The void longjmp( jmp-buf env, int val) function causes setjmp() macro to return_______value; if val is 0.

A. zero
B. one
C. NULL
D. no return
Answer» C. NULL
22.

Which of the given options is an array type used for holding information?

A. longjmp
B. setjmp
C. jmp_buf
D. no such variable
Answer» D. no such variable
23.

Which of the following header file defines one function longjmp(), and one variable type jmp_buf?

A. stdarg.h
B. locale.h
C. setjmp.h
D. stdlib.h
Answer» D. stdlib.h