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 9

1. Which of the following statements about signed integer overflow in C is correct?
A) It wraps around modulo 2^n
B) It is undefined behavior
C) It is implementation-defined
D) It always triggers an exception

B) It is undefined behavior

2. What does “effective type” refer to (for strict aliasing rules)?
A) The declared type of a variable only
B) The type used to access stored value in an object
C) The return type of a function
D) The size_t type

B) The type used to access stored value in an object

3. Which of the following is true about memcpy() when source and destination overlap?
A) It works correctly always
B) Behavior is undefined
C) It behaves like memmove()
D) It copies in reverse order

B) Behavior is undefined

4. Which of the following best describes “translation unit” in C?
A) A single function file
B) A source file after preprocessing
C) A header file only
D) A compiled object file only

B) A source file after preprocessing

5. Which of the following is true about the order of evaluation of function arguments in C?
A) Left to right always
B) Right to left always
C) Unspecified
D) Depends on -O0 or -O2 only

C) Unspecified

6. Which of the following is guaranteed by the C standard about NULL?
A) NULL is always (void*)0
B) NULL is always 0
C) NULL is a null pointer constant
D) NULL cannot be used with integers

C) NULL is a null pointer constant

7. What does the _Generic keyword provide (C11)?
A) Reflection
B) Generic selection based on type
C) Thread creation
D) Automatic memory management

B) Generic selection based on type

8. Which of the following statements about volatile is correct?
A) It makes operations atomic
B) It is required for multithreading correctness always
C) It prevents certain optimizations on accesses
D) It guarantees memory ordering between threads

C) It prevents certain optimizations on accesses

9. Which function is used to compare memory blocks byte-by-byte?
A) strcmp()
B) memcmp()
C) memmove()
D) memcpy()

B) memcmp()

10. Which header defines the type ptrdiff_t?
A) stdio.h
B) stddef.h
C) stdlib.h
D) string.h

B) stddef.h

11. Which of the following is true about char signedness in C?
A) char is always signed
B) char is always unsigned
C) char may be signed or unsigned depending on implementation
D) char is always 8-bit signed

C) char may be signed or unsigned depending on implementation

12. What does the macro __STDC_VERSION__ indicate?
A) The compiler vendor
B) The C standard version supported
C) The target OS
D) The CPU architecture

B) The C standard version supported

13. Which of the following is a correct statement about alignment?
A) Alignment never matters in C
B) Misaligned access is always safe
C) Some types require specific alignment; misalignment may cause UB
D) Alignment depends only on variable name length

C) Some types require specific alignment; misalignment may cause UB

14. Which of the following statements about bitwise shifts is correct?
A) Left shift of 1 into sign bit is always defined
B) Right shift of unsigned is logical shift
C) Right shift of signed is always arithmetic shift
D) Shifts are defined for any shift count

B) Right shift of unsigned is logical shift

15. Which of the following is true about the lifetime of a string literal?
A) Until end of block
B) Until function returns
C) Entire program execution
D) Until first modification

C) Entire program execution

16. Which of the following is true about “extern int x;” in a header?
A) It defines x and allocates storage
B) It declares x; definition must be elsewhere
C) It makes x local to each file
D) It initializes x to 0 in each file

B) It declares x; definition must be elsewhere

17. What does the preprocessor directive #pragma once do (conceptually)?
A) Ensures a header is included only once per translation unit
B) Disables all warnings
C) Converts code to assembly
D) Forces inline expansion

A) Ensures a header is included only once per translation unit

18. Which of the following is true about variable length arrays (VLA)?
A) They are part of C89
B) They must have constant size
C) Their size is determined at runtime
D) They are stored only on heap

C) Their size is determined at runtime

19. Which of the following functions can cause undefined behavior if used with overlapping memory?
A) memmove()
B) memcpy()
C) memset()
D) memcmp()

B) memcpy()

20. Which C11 feature introduces atomic operations?
A) stdio.h
B) stdatomic.h
C) stdalign.h
D) threads.h

B) stdatomic.h

21. Which of the following is true about the function abort()?
A) It returns to caller with error code
B) It performs normal cleanup like exit()
C) It terminates program abnormally
D) It frees all heap memory safely

C) It terminates program abnormally

22. Which is the correct statement about the return value of realloc(p,0)?
A) Always returns NULL and frees p
B) Always returns p unchanged
C) Behavior is implementation-defined (may free and return NULL)
D) Causes compilation error

C) Behavior is implementation-defined (may free and return NULL)

23. Which header is used for setjmp and longjmp?
A) stdio.h
B) setjmp.h
C) stdlib.h
D) signal.h

B) setjmp.h

24. Which is true about the expression: (int)(uintptr_t)p
A) Always safe conversion from pointer to int
B) Used for portable pointer-to-integer conversion via uintptr_t
C) Causes undefined behavior always
D) Converts int to pointer

B) Used for portable pointer-to-integer conversion via uintptr_t

25. Which of the following is true about “_Alignof(type)” (C11)?
A) Returns size of type
B) Returns alignment requirement of type
C) Returns pointer difference
D) Returns number of members

B) Returns alignment requirement of type