A Learning Platform

SUCCESS

Success = Discipline + Consistency + Sacrifice.
Discipline - in what you do.
Consistency - in what you do.
Sacrifice - for what you do.

                   -- Manjunatha C. P. --

C PROGRAMMING MCQ SET 10

1. Which of the following is true about the comma operator in C?
A) It has the highest precedence
B) It evaluates both operands but returns the first
C) It evaluates left operand, discards it, and returns the right operand
D) It can only be used in for loops

C) It evaluates left operand, discards it, and returns the right operand

2. Which of the following statements about inline functions is correct?
A) inline guarantees no function call overhead
B) inline functions must be defined in header files
C) inline is only a suggestion to the compiler
D) inline works only for recursive functions

C) inline is only a suggestion to the compiler

3. What does the macro __FILE__ expand to?
A) File descriptor number
B) Current function name
C) Current source file name
D) Compilation date

C) Current source file name

4. Which of the following is true about const-qualified objects?
A) They are stored only in ROM
B) They cannot be modified through any pointer
C) Modifying them through cast may cause undefined behavior
D) They must be global

C) Modifying them through cast may cause undefined behavior

5. Which of the following best describes a “tentative definition”?
A) A declaration without data type
B) A declaration without storage allocation unless no definition appears
C) A macro definition
D) A forward declaration of function

B) A declaration without storage allocation unless no definition appears

6. Which of the following guarantees that a signal handler sees updated variable values?
A) static
B) volatile
C) register
D) inline

B) volatile

7. Which of the following is true about errno?
A) It is cleared automatically before every library call
B) It is thread-local in modern C implementations
C) It must be declared by the programmer
D) It stores compiler error codes

B) It is thread-local in modern C implementations

8. Which of the following operations is NOT allowed on void pointers?
A) Assignment
B) Comparison
C) Dereferencing
D) Conversion to another pointer type

C) Dereferencing

9. Which statement about flexible array members is correct?
A) They can appear anywhere in the structure
B) They must be the last member of a structure
C) They allocate memory automatically
D) Their size must be constant

B) They must be the last member of a structure

10. What is the output of: printf("%d", sizeof('A'));
A) 1
B) 2
C) sizeof(char)
D) sizeof(int)

D) sizeof(int)

11. Which of the following is guaranteed to be true for free(NULL)?
A) Causes segmentation fault
B) Undefined behavior
C) Has no effect
D) Frees all memory

C) Has no effect

12. Which of the following best describes object lifetime in C?
A) Time variable exists in source code
B) Time memory is allocated for an object
C) Time function executes
D) Time compiler optimizes code

B) Time memory is allocated for an object

13. Which of the following expressions may invoke undefined behavior?
A) i = i + 1;
B) i++;
C) i = ++i;
D) i += 1;

C) i = ++i;

14. Which C standard introduced threads support?
A) C89
B) C99
C) C11
D) C17

C) C11

15. Which of the following headers provides aligned_alloc()?
A) stdio.h
B) stdlib.h
C) stdalign.h
D) malloc.h

B) stdlib.h

16. Which statement about unions is correct?
A) All members exist simultaneously
B) Size equals sum of all members
C) Only one member holds a value at a time
D) Union members must be same type

C) Only one member holds a value at a time

17. Which of the following is NOT a valid use of goto?
A) Exiting nested loops
B) Implementing finite state machines
C) Jumping into a block with initialized variables
D) Error handling cleanup

C) Jumping into a block with initialized variables

18. Which of the following is true about signedness of bit-fields?
A) Bit-fields are always unsigned
B) Bit-fields are always signed
C) Signedness depends on declared type
D) Bit-fields cannot be signed

C) Signedness depends on declared type

19. What does the expression sizeof(struct S *) return?
A) Size of structure
B) Size of pointer to structure
C) Sum of members
D) Depends on number of fields

B) Size of pointer to structure

20. Which of the following is guaranteed to be evaluated first?
A) Function arguments
B) Operands of +
C) Operand of sizeof
D) Operands of =

C) Operand of sizeof

21. Which macro expands to the current function name (C99+)?
A) __FUNC__
B) __FUNCTION__
C) __func__
D) __method__

C) __func__

22. Which of the following can cause strict aliasing violations?
A) Accessing object through unsigned char*
B) Accessing object through compatible type
C) Accessing int object through float*
D) Using memcpy()

C) Accessing int object through float*

23. Which function can be safely called inside a signal handler?
A) printf()
B) malloc()
C) free()
D) write()

D) write()

24. Which of the following is true about “_Noreturn” keyword?
A) It forces function to return zero
B) It indicates function never returns to caller
C) It makes function inline
D) It disables warnings

B) It indicates function never returns to caller

25. Which of the following best describes C language design?
A) Memory-safe by default
B) Low-level with minimal runtime
C) Fully object-oriented
D) Automatically garbage collected

B) Low-level with minimal runtime