

MCQOPTIONS
Saved Bookmarks
This section includes 45 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
In the following code snippet can we declare a new named even though has not been completely declared while using ? |
A. | Yes |
B. | No |
Answer» B. No | |
2. |
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 | |
3. |
Is the following declaration acceptable? |
A. | Yes |
B. | NO |
Answer» B. NO | |
4. |
Is there any difference in the and in the following code? |
A. | Yes |
B. | No |
Answer» B. No | |
5. |
Are the properties of and in the following program same? |
A. | Yes |
B. | No |
Answer» B. No | |
6. |
's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas 's always have a global effect. |
A. | Yes |
B. | No |
Answer» B. No | |
7. |
In the following code, the is Integer Pointer or Integer? |
A. | Integer |
B. | Integer pointer |
C. | Error in declaration |
D. | None of above |
Answer» C. Error in declaration | |
8. |
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 | |
9. |
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 | |
10. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | 44 |
C. | 22 |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
11. |
Which option should be selected to work the following C expression?
|
A. | Such expression cannot be generated in C |
B. | typedef char [] string; |
C. | typedef char *string; |
D. | typedef char [] string; and typedef char *string; |
E. | None of these |
Answer» D. typedef char [] string; and typedef char *string; | |
12. |
What will be the output of the following C code?
|
A. | Depends on the standard |
B. | 11 |
C. | 22 |
D. | Garbage value |
E. | Compilation Error |
Answer» F. | |
13. |
Which of the following will be the correct output for the program given below ?
|
A. | 1 2 3 4 |
B. | 1 2 3 4 5 |
C. | No output |
D. | Error: Cannot use typedef with an array |
Answer» B. 1 2 3 4 5 | |
14. |
What will be the output of the following C code?
|
A. | 10 |
B. | 20 |
C. | Compilation Error |
D. | Undefined behaviour |
E. | None of these |
Answer» D. Undefined behaviour | |
15. |
What will be the output of the following C code?
|
A. | Nothing |
B. | Undefined behaviour |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
16. |
What will be the output of the following C code?
|
A. | 250 |
B. | Compilation Error |
C. | Garbage value |
D. | 120 |
E. | None of these |
Answer» E. None of these | |
17. |
What will be the output of the following C code?
|
A. | Welcome |
B. | Compilation Error |
C. | Garbage value |
D. | Undefined behaviour |
E. | None of these |
Answer» B. Compilation Error | |
18. |
Which of the given option is the correct method for initialization?
|
A. | Not more than one space should be given when using typedef |
B. | *string *q = Welcome ; |
C. | string p = Welcome ; |
D. | *string p = B ; |
E. | None of these |
Answer» D. *string p = B ; | |
19. |
What will be the output of the following C code?
|
A. | Compilation Error |
B. | Garbage value |
C. | hello |
D. | Undefined behaviour |
E. | None of these |
Answer» B. Garbage value | |
20. |
What will be the output of the following C code?
|
A. | Hello |
B. | Garbage value |
C. | Compilation Error |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
21. |
In the following code, the P2 is Integer Pointer or Integer?_x000D_ typedef int *ptr;_x000D_ ptr p1, p2; |
A. | Integer |
B. | Integer pointer |
C. | Error in declaration |
D. | None of above |
Answer» C. Error in declaration | |
22. |
What will be the output of the program?_x000D_
#include
|
A. | 0 |
B. | 1 |
C. | 2 |
D. | Error |
Answer» C. 2 | |
23. |
What will be the output of the program?_x000D_
#include
|
A. | 1, 2, 3, 4 |
B. | 1, 2, 3, 4, 5 |
C. | No output |
D. | Error: Cannot use typedef with an array |
Answer» B. 1, 2, 3, 4, 5 | |
24. |
What will be the output of the program?_x000D_
#include
|
A. | 72, 68.000000 |
B. | 72.000000, 68 |
C. | 68.000000, 72.000000 |
D. | 68, 72.000000 |
Answer» B. 72.000000, 68 | |
25. |
Are the properties of i, j and x, y in the following program same?_x000D_ typedef unsigned long int uli;_x000D_ uli i, j;_x000D_ unsigned long int x, y; |
A. | Yes |
B. | No |
Answer» B. No | |
26. |
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 | |
27. |
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 | |
28. |
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 bytesView Answer |
E. | a) 5 bytesb) 10 bytesc) 40 bytesd) 50 bytesView Answer |
Answer» E. a) 5 bytesb) 10 bytesc) 40 bytesd) 50 bytesView Answer | |
29. |
The keyword typedef cannot be used to give alias names to pointers. |
A. | True |
B. | False |
Answer» C. | |
30. |
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; | |
31. |
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 | |
32. |
What will be the output of the program?
#include
|
A. | 9 |
B. | 0 |
C. | 90 |
D. | 90 |
Answer» D. 90 | |
33. |
What will be the output of the program?
#include
|
A. | 72, 68.000000 |
B. | 72.000000, 68 |
C. | 68.000000, 72.000000 |
D. | 68, 72.000000 |
Answer» B. 72.000000, 68 | |
34. |
What will be the output of the program?
#include
|
A. | 1, 2, 3, 4 |
B. | 1, 2, 3, 4, 5 |
C. | No output |
D. | Error: Cannot use typedef with an array |
Answer» B. 1, 2, 3, 4, 5 | |
35. |
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 | |
36. |
Point out the error in the following code? typedef struct { int data; NODEPTR link; }*NODEPTR; |
A. | Error: in *NODEPTR |
B. | Error: typedef cannot be used until it is defined |
C. | No error |
D. | None of above |
Answer» C. No error | |
37. |
What will be the output of the program?
#include
|
A. | 0 |
B. | 1 |
C. | 2 |
D. | Error |
Answer» C. 2 | |
38. |
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 | |
39. |
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 | |
40. |
What is x in the following program?
#include
|
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 | |
41. |
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 | |
42. |
What will be the output of the program?
#include
|
A. | 1 |
B. | 0 |
C. | 2 |
D. | red |
Answer» C. 2 | |
43. |
Is the following declaration acceptable? typedef long no, *ptrtono; no n; ptrtono p; |
A. | Yes |
B. | NO |
C. | Yes |
D. | No |
Answer» B. NO | |
44. |
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 |
C. | Error: in *NODEPTR |
D. | Error: typedef cannot be used until it is defined |
Answer» B. No | |
45. |
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 | |