

MCQOPTIONS
This section includes 55 Mcqs, each offering curated multiple-choice questions to sharpen your Typedef knowledge and support exam preparation. Choose a topic below to get started.
1. |
typedef's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas #define's always have a global effect. |
A. | Yes |
B. | No |
Answer» B. No | |
2. |
Are the properties of i, j and x, y in the following program same?
|
A. | Yes |
B. | No |
Answer» B. No | |
3. |
Is there any difference in the #define and typedef in the following code?
|
A. | Yes |
B. | No |
Answer» B. No | |
4. |
Is the following declaration acceptable?
|
A. | Yes |
B. | NO |
Answer» B. NO | |
5. |
In the following code snippet can we declare a new typedef named ptr even though struct employee has not been completely declared while using typedef?
|
A. | Yes |
B. | No |
Answer» B. No | |
6. |
Point out the error in the following code?
|
A. | Error: in *NODEPTR |
B. | Error: |
C. | cannot be used until it is defined |
D. | No error |
E. | None of above |
Answer» C. cannot be used until it is defined | |
7. |
What will be the output of the program?
|
A. | 1 |
B. | 2 |
C. | Error |
Answer» C. Error | |
8. |
What will be the output of the program?
|
A. | 9 |
B. | 90.000000 |
C. | 90 |
Answer» D. | |
9. |
What will be the output of the program?
|
A. | 72, 68.000000 |
B. | 72.000000, 68 |
C. | 68.000000, 72.000000 |
D. | 68, 72.000000 |
Answer» B. 72.000000, 68 | |
10. |
What will be the output of the program?
|
A. | 1 |
B. | 2 |
C. | red |
Answer» A. 1 | |
11. |
Which of the following is an example for non linear data type? |
A. | Tree |
B. | Array |
C. | Linked list |
D. | Queue |
Answer» B. Array | |
12. |
Queue data structure works on the principle of ____________ |
A. | Last In First Out (LIF0) |
B. | First In Last Out (FILO) |
C. | First In First Out (FIFO) |
D. | Last In Last Out (LILO) |
Answer» D. Last In Last Out (LILO) | |
13. |
The type of linked list in which the node does not contain any pointer or reference to the previous node is _____________ |
A. | Circularly singly linked list |
B. | Singly linked list |
C. | Circular doubly linked list |
D. | Doubly linked list |
Answer» C. Circular doubly linked list | |
14. |
Which of the following header files must necessarily be included to use dynamic memory allocation functions? |
A. | stdlib.h |
B. | stdio.h |
C. | memory.h |
D. | dos.h |
Answer» B. stdio.h | |
15. |
Choose the statement which is incorrect with respect to dynamic memory allocation. |
A. | Memory is allocated in a less structured area of memory, known as heap |
B. | Used for unpredictable memory requirements |
C. | Execution of the program is faster than that of static memory allocation |
D. | Allocated memory can be changed during the run time of the program based on the requirement of the program |
Answer» D. Allocated memory can be changed during the run time of the program based on the requirement of the program | |
16. |
The size of both stack and heap remains the same during run time. |
A. | True |
B. | False |
Answer» C. | |
17. |
Local variables are stored in an area called ___________ |
A. | Heap |
B. | Permanent storage area |
C. | Free memory |
D. | Stack |
Answer» E. | |
18. |
What is typedef declaration? |
A. | Does not create a new type |
B. | It merely adds a new name for some existing type |
C. | Does not create a new type, It merely adds a new name for some existing type |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
19. |
typedef int (*PFI)(char *, char *)creates ___________ |
A. | type PFI, for pointer to function (of two char * arguments) returning int |
B. | error |
C. | type PFI, function (of two char * arguments) returning int |
D. | type PFI, for pointer |
Answer» B. error | |
20. |
Which of the following may create problem in the typedef program? |
A. | ; |
B. | printf/scanf |
C. | Arithmetic operators |
D. | All of the mentioned |
Answer» E. | |
21. |
Which of the given option is the correct method for initialization?
|
A. | *string *p = Hello ; |
B. | string p = Hello ; |
C. | *string p = A ; |
D. | Not more than one space should be given when using typedef |
Answer» C. *string p = A ; | |
22. |
Which option should be selected to work the following C expression?
|
A. | typedef char [] string; |
B. | typedef char *string; |
C. | typedef char [] string; and typedef char *string; |
D. | Such expression cannot be generated in C |
Answer» C. typedef char [] string; and typedef char *string; | |
23. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | 1 |
C. | Depends on the standard |
Answer» C. Depends on the standard | |
24. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | 1 |
C. | Depends on the standard |
Answer» B. 1 | |
25. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | 1 |
C. | Depends on the standard |
Answer» B. 1 | |
26. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | Nothing |
C. | Undefined behaviour |
D. | D. |
Answer» C. Undefined behaviour | |
27. |
We want to create an alias name for an identifier of the type unsigned long. The alias name is: ul. The correct way to do this using the keyword typedef is ____________ |
A. | typedef unsigned long ul; |
B. | unsigned long typedef ul; |
C. | typedef ul unsigned long; |
D. | ul typedef unsigned long; |
Answer» B. unsigned long typedef ul; | |
28. |
Which of the following keywords is used to define an alternate name for an already existing data type? |
A. | default |
B. | volatile |
C. | typedef |
D. | static |
Answer» D. static | |
29. |
What will be the output of following program ?
|
A. | Error |
B. | 10,10,10,10 |
C. | 10,20,30,40 |
D. | AAA,BBB,CCC,DDD |
Answer» D. AAA,BBB,CCC,DDD | |
30. |
What is x in the following program?
|
A. | x is a pointer |
B. | x is an array of three pointer |
C. | x is an array of three function pointers |
D. | Error in x declaration |
Answer» D. Error in x declaration | |
31. |
In the following code what is 'P'?
|
A. | P is a constant |
B. | P is a character constant |
C. | P is character type |
D. | None of above |
Answer» B. P is a character constant | |
32. |
In the following code, the P2 is Integer Pointer or Integer?
|
A. | Integer |
B. | Integer pointer |
C. | Error in declaration |
D. | None of above |
Answer» C. Error in declaration | |
33. |
For the following typedef in C, pick the best statement typedef int INT, *INTPTR, ONEDARR[10], TWODARR[10][10]; |
A. | It will cause compile error because typedef is being used to define multiple aliases of incompatible types in the same statement. |
B. | INT x would define x of type int. Remaining part of the statement would be ignored. |
C. | INT x would define x of type int and INTPTR y would define pointer y of type int *. Remaining part of the statement would be ignored. |
D. | INT x would define x of type int. INTPTR *y would define pointer y of type int **. ONEDARR z would define z as array of 10 int. TWODARR t would define t as array of 10 by 10 int. |
Answer» E. | |
34. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | Undefined behaviour |
C. | Depends on the standard |
D. | 10 |
Answer» E. | |
35. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | Nothing |
C. | Undefined behaviour |
D. | Depends on the standard |
Answer» B. Nothing | |
36. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | Varies |
C. | he |
D. | hey |
Answer» E. | |
37. |
What will be the output of the following C code?
|
A. | Compile time error |
B. | Varies |
C. | hi |
D. | h |
Answer» B. Varies | |
38. |
What will be the output of the following C code?
|
A. | 2, 3 |
B. | 3, 2 |
C. | 32 |
D. | error |
Answer» C. 32 | |
39. |
One of the major difference between typedef and #define is that typedef interpretation is performed by the _________________ whereas #define interpretation is performed by the _____________ |
A. | pre-processor, compiler |
B. | user, pre-processor |
C. | compiler, pre-processor |
D. | compiler, user |
Answer» D. compiler, user | |
40. |
Consider this statement: typedef enum good {a, b, c} hello; Which of the following statements is incorrect about hello? |
A. | hello is a typedef of enum good |
B. | hello is a structure |
C. | hello is a variable of type enum good |
D. | the statement shown above is erroneous |
Answer» B. hello is a structure | |
41. |
What is the size of myArray in the code shown below? (Assume that 1 character occupies 1 byte)
|
A. | 5 bytes |
B. | 10 bytes |
C. | 40 bytes |
D. | 50 bytes |
Answer» E. | |
42. |
We want to declare x, y and z as pointers of type int. The alias name given is: intpt The correct way to do this using the keyword typedef is: |
A. | int typedef* intptr; int x,y,z; |
B. | typedef* intptr; int x,y,z; |
C. | int typedef* intptr; intptr x,y,z; |
D. | typedef int* intptr; intptr x,y,z; |
Answer» E. | |
43. |
What s the meaning of following declaration in C language?
|
A. | It will result in compile error because there shouldn't be any parenthesis i.e. int *p[5] is valid. |
B. | p is a pointer to 5 integers |
C. | p is a pointer to integer array. |
D. | p is a pointer to an array of 5 integers |
Answer» E. | |
44. |
Assuming int size is 4 bytes, what is going to happen when we compile and run the following program?
|
A. | We can t use main() inside main() and compiler will catch it by showing compiler error. |
B. | GeeksQuiz would be printed in 2147483647 times i.e. (2 to the power 31) - 1. |
C. | It ll print GeeksQuiz infinite times i.e. the program will continue to run forever until it s terminated by other means such as CTRL+C or CTRL+Z etc. |
D. | GeeksQuiz would be printed until stack overflow happens for this program. |
Answer» E. | |
45. |
typedef declaration: |
A. | Does not create a new type |
B. | It merely adds a new name for some existing type. |
C. | Both a & b |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
46. |
What is the output of this C code?
|
A. | Compile time error |
B. | 1 |
C. | Depends on the standard |
Answer» C. Depends on the standard | |
47. |
typedef which of the following may create problem in the program? |
A. | ; |
B. | printf/scanf |
C. | Arithmetic operators |
D. | All of the mentioned. |
Answer» E. | |
48. |
typedef int (*PFI)(char *, char *)creates: |
A. | type PFI, for pointer to function (of two char * arguments) returning int |
B. | Error |
C. | type PFI, function (of two char * arguments) returning int |
D. | type PFI, for pointer |
Answer» B. Error | |
49. |
Which of the following is FALSE about typedef? |
A. | typedef follow scope rules |
B. | typedef defined substitutes can be redefined again. (Eg: typedef char a; typedef int a;) |
C. | You cannot typedef a typedef with other term. |
D. | All of the mentioned |
Answer» C. You cannot typedef a typedef with other term. | |
50. |
Which of the given option is the correct method for initialization? |
A. | *string *p = Hello ; |
B. | string p = Hello ; |
C. | *string p = A ; |
D. | Not more than one space should be given when using typedef |
Answer» C. *string p = A ; | |