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 13

1. Which phase of translation handles string literal concatenation?
A) Phase 3
B) Phase 4
C) Phase 6
D) Phase 7

C) Phase 6

2. Which of the following is guaranteed about character literals like 'A'?
A) Type is char
B) Type is int
C) Size is 1 byte
D) Same as string literal

B) Type is int

3. Which of the following is true about accessing an object through unsigned char*?
A) Causes strict aliasing violation
B) Undefined behavior
C) Always allowed
D) Only allowed for structs

C) Always allowed

4. Which of the following best describes “observable behavior”?
A) Compiler optimization result
B) Output to files, volatile access, I/O
C) Internal register changes
D) Stack pointer movement

B) Output to files, volatile access, I/O

5. Which of the following expressions has undefined behavior?
A) i = i + 1;
B) i++;
C) i = i++;
D) i += 1;

C) i = i++;

6. Which of the following is guaranteed about sizeof?
A) Returns int
B) Returns long
C) Returns size_t
D) Returns unsigned int

C) Returns size_t

7. Which statement about “effective type” is correct?
A) It is always the declared type
B) It applies only to unions
C) It determines valid memory access for aliasing
D) It is ignored by compiler

C) It determines valid memory access for aliasing

8. Which of the following is NOT a valid storage duration?
A) Automatic
B) Static
C) Dynamic
D) Temporary

D) Temporary

9. Which of the following is true about alignment requirements?
A) Ignoring alignment is always safe
B) Alignment applies only to structs
C) Misaligned access can cause undefined behavior
D) Alignment affects only performance

C) Misaligned access can cause undefined behavior

10. Which macro expands to the current function name?
A) __FUNCTION__
B) __FUNC__
C) __func__
D) __METHOD__

C) __func__

11. Which statement about volatile is correct?
A) Makes operations atomic
B) Prevents reordering across threads
C) Prevents certain compiler optimizations
D) Ensures memory consistency

C) Prevents certain compiler optimizations

12. Which of the following is guaranteed to be evaluated?
A) Both operands of &&
B) Second operand of ||
C) Operand of sizeof
D) All function arguments

C) Operand of sizeof

13. Which of the following describes “tentative definition”?
A) Function prototype
B) Declaration without initializer at file scope
C) Macro definition
D) Inline function

B) Declaration without initializer at file scope

14. Which of the following is implementation-defined?
A) Signed integer overflow
B) Order of evaluation of expressions
C) Size of int
D) Dereferencing NULL pointer

C) Size of int

15. Which header defines max_align_t?
A) stdio.h
B) stdalign.h
C) stddef.h
D) stdint.h

C) stddef.h

16. Which of the following is guaranteed by the C standard?
A) Two’s complement representation
B) sizeof(int) == 4
C) sizeof(char) == 1
D) char is signed

C) sizeof(char) == 1

17. Which of the following statements about macros is true?
A) Macros perform type checking
B) Macro arguments are evaluated once
C) Macros are expanded before compilation
D) Macros are safer than inline functions

C) Macros are expanded before compilation

18. Which of the following is NOT allowed by the C standard?
A) Pointer arithmetic within array
B) One past the end pointer
C) Dereferencing one past the end pointer
D) Comparing pointers within same array

C) Dereferencing one past the end pointer

19. Which function guarantees flushing of all output streams?
A) fflush(NULL)
B) exit()
C) abort()
D) fcloseall()

B) exit()

20. Which of the following best defines “constraint violation”?
A) Runtime error
B) Undefined behavior
C) Requires diagnostic from compiler
D) Optimization failure

C) Requires diagnostic from compiler

21. Which C11 feature enables compile-time assertions?
A) assert()
B) _Static_assert
C) static_assert
D) pragma assert

B) _Static_assert

22. Which of the following is guaranteed async-signal-safe?
A) printf()
B) malloc()
C) write()
D) free()

C) write()

23. Which of the following best describes C’s memory model?
A) Managed and safe
B) Strictly sequential
C) Flat memory with explicit control
D) Object-oriented

C) Flat memory with explicit control

24. Which operator has the lowest precedence?
A) =
B) &&
C) ||
D) ,

D) ,

25. Which statement best summarizes C language philosophy?
A) Programmer protection
B) Safety-first design
C) Trust the programmer
D) Automatic correctness

C) Trust the programmer