C- Typedef Questions and Answers
The typedef keyword in C programming allows developers to create new data type names, simplifying complex declarations. This topic is commonly covered in programming questions and answers during technical interviews and placement tests conducted by TCS, Infosys, Wipro, and HCL. Understanding how typedef improves code readability and portability is crucial for writing clean, efficient programs. In this section, you’ll find C typedef questions with answers and explanations that illustrate its real-world usage, especially in defining structures and pointers. Practicing these C programming MCQs enhances your conceptual clarity and prepares you for coding rounds and technical interviews effectively.
C- Typedef
Showing 10 of
23 questions
11. What happens when we use typedef with a structure without a tag?
- Compiler error
- Creates type alias for anonymous structure
- Creates global variable
- Nothing happens
12. Which scope does typedef follow?
- Global scope only
- File scope only
- Follows normal C scope rules
- Function scope only
13. What is the difference between typedef and #define?
- No difference
- typedef is for constants, #define for types
- typedef is interpreted by compiler, #define by preprocessor
- #define is more powerful
14. Can typedef be used to create a new data type?
- Yes, always
- No, it only creates aliases
- Only with structures
- Only with pointers
15. How to use typedef with enum?
- typedef enum {RED, BLUE} Colors;
- enum typedef Colors {RED, BLUE};
- typedef {RED, BLUE} Colors;
- enum Colors typedef {RED, BLUE};
16. What is the output of: typedef int Integer; Integer x = 5; printf("%d", x);
- 0
- 5
- Garbage value
- Compiler error
17. Which is better for type checking: typedef or #define?
- Both are same
- typedef provides better type checking
- #define provides better type checking
- Neither provides type checking
18. Can we use typedef inside a function?
- No, typedef is always global
- Yes, typedef can have local scope
- Only in main function
- Only with primitive types
19. What does typedef unsigned int UINT; do?
- Declares UINT variable
- Creates UINT as alias for unsigned int
- Defines UINT constant
- Includes UINT header
20. How to declare multiple typedefs in one statement?
- typedef int a, b, c;
- typedef int a; typedef int b; typedef int c;
- typedef int a, b, c; is invalid
- typedef (int a, int b, int c);