

MCQOPTIONS
Saved Bookmarks
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? typedef unsigned long int uli; uli i, j; unsigned long int x, y; |
A. | Yes |
B. | No |
Answer» B. No | |
3. |
Is there any difference in the #define and typedef in the following code? typedef char * string_t; #define string_d char *; string_t s1, s2; string_d s3, s4; |
A. | Yes |
B. | No |
Answer» B. No | |
4. |
Is the following declaration acceptable? typedef long no, *ptrtono; no n; ptrtono p; |
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? typedef struct employee *ptr; struct employee { char name[20]; int age; ptr next; } |
A. | Yes |
B. | No |
Answer» B. No | |
6. |
Point out the error in the following code? typedef struct { int data; NODEPTR link; }*NODEPTR; |
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? #include typedef struct error {int warning, err, exception;} ERROR; int main() { ERROR e; e.err=1; printf("%d n", e.err); return 0; } |
A. | 1 |
B. | 2 |
C. | Error |
Answer» C. Error | |
8. |
What will be the output of the program? #include int main() { typedef float f; static f *fptr; float fval = 90; fptr = &fval; printf("%f n", *fptr); return 0; } |
A. | 9 |
B. | 90.000000 |
C. | 90 |
Answer» D. | |
9. |
What will be the output of the program? #include int main() { typedef int LONG; LONG a=4; LONG b=68; float c=0; c=b; b+=a; printf("%d,", b); printf("%f n", c); retu |
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? #include int main() { enum color{red, green, blue}; typedef enum color mycolor; mycolor m = red; printf("%d", m); return 0; } |
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? typedef char *string; |
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? string p = "HELLO"; |
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? #include typedef struct p { int x, y; }k; int main() { struct p p = {1, 2}; k k1 = p; printf("%d n", k1.x); } |
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? #include typedef struct p { int x, y; }; int main() { p k1 = {1, 2}; printf("%d n", k1.x); } |
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? #include typedef struct p { int x, y; }k = {1, 2}; int main() { p k1 = k; printf("%d n", k1.x); } |
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? #include int *(*(x()))[2]; typedef int **(*ptrfoo)())[2]; int main() { ptrfoo ptr1; ptr1 = x; ptr1(); return 0; } int *(*(x()))[2] { int (*ary)[2] = malloc(sizeof * ary); return &ary; } |
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 ? #include < stdio> int main() { typedef int AAA,BBB,CCC,DDD; AAA aaa=10; BBB bbb=20; CCC ccc=30; DDD ddd=40; printf("%d,%d,%d,%d",aaa,bbb,ccc,ddd); return 0; } |
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? #include int main() { typedef char (*(*arrfptr[3])())[10]; arrfptr x; return 0; } |
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'? typedef char *charp; const charp 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? typedef int *ptr; ptr p1, p2; |
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? #include typedef int integer; int main() { int i = 10, *ptr; float f = 20; integer j = i; ptr = &j; printf("%d n", *ptr); return 0; } |
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? #include int (*(x()))[2]; typedef int (*(*ptr)())[2] ptrfoo; int main() { ptrfoo ptr1; ptr1 = x; ptr1(); return 0; } int (*(x()))[2] { int (*ary)[2] = malloc(sizeof*ary); return &ary; } |
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? #include typedef struct student { char *a; }stu; void main() { struct student s; s.a = "hey"; printf("%s", s.a); } |
A. | Compile time error |
B. | Varies |
C. | he |
D. | hey |
Answer» E. | |
37. |
What will be the output of the following C code? #include typedef struct student { char *a; }stu; void main() { struct stu s; s.a = "hi"; printf("%s", s.a); } |
A. | Compile time error |
B. | Varies |
C. | hi |
D. | h |
Answer» B. Varies | |
38. |
What will be the output of the following C code? #include int main() { typedef union a { int i; char ch[2]; }hello; hello u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d", u.ch[0], u.ch[1]); return 0; } |
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) typedef char x[10]; x myArray[5]; |
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? int (*p)[5]; |
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? #include stdio.h int main() { printf( GeeksQuizn ); main(); return 0; } |
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? typedef struct p { int x, y; }k; int main() { struct p p = {1, 2}; k k1 = p; printf("%d n", k1.x); } |
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? typedef char *string; |
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 ; | |