Explore topic-wise MCQs in C Programming.

This section includes 23 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.

What will be the output of the following C code (considering sizeof char is 1 and pointer is 4)?

A. 1
B. 2
C. 3
D. 4
E. Depends on compiler
Answer» F.
2.

Which is true for number, if number is defined as int *number[15]; ?

A. Error
B. The definition only allocates 15 pointers and does not initialize them & Initialization must be done explicitly
C. Initialization must be done explicitly
D. The definition only allocates 15 pointers and does not initialize them
E. None of these
Answer» C. Initialization must be done explicitly
3.

Which is true for num, if num is defined as int num[12][23]; ?

A. The conventional rectangular subscript calculation 20 * row + col is used to find the element num[row, col].
B. num is true two-dimensional array
C. 200 int-sized locations have been set aside
D. All of above
E. None of these
Answer» E. None of these
4.

Which of the following operation is possible using a pointer char? (Assuming the declaration is char *ch;)

A. Generation of the multidimensional array
B. Changing address to point at another location
C. Input via %s
D. All of above
E. None of these
Answer» C. Input via %s
5.

Comment on the following two operations.

A. Neither of them work
B. I works, II doesn t
C. II works, I doesn t
D. Both of them work
E. None of these
Answer» E. None of these
6.

Which function is not called in the following C program?

A. Function "f"
B. Function "fun"
C. Function "function"
D. All of above
E. None of these
Answer» F.
7.

Comment on the following declaration.

A. Both i) and ii) will work legal and flawlessly
B. i) is illegal, ii) is legal
C. i) is legal, ii) is illegal
D. Both i) and ii) and cannot exist due to same name
E. None of these
Answer» B. i) is illegal, ii) is legal
8.

What makes the following declaration denote?

A. p is a pointer to an int pointer
B. p is a pointer to pointer to type int
C. p is a function pointer that returns pointer to int type
D. All of above
E. None of these
Answer» B. p is a pointer to pointer to type int
9.

Read the following expression?

A. p is pointer to function passing void returning int
B. p is pointer to void that converts its type to int
C. p is pointer to function passing int returning void
D. p is pointer to int that converts its type to void
E. None of these
Answer» D. p is pointer to int that converts its type to void
10.

What does this declaration say?

A. B is function which returns array of integers
B. B is function which returns function pointer which in turn returns pointer to integer array
C. B is pointer to the function which returns array of pointers
D. B is pointer to the function which returns pointer to integer array
E. None of these
Answer» E. None of these
11.

Is the below declaration legal?

A. Undefined behaviour
B. True
C. False
D. Depends on the standard
E. None of these
Answer» D. Depends on the standard
12.

Which of following logical operation can be applied to pointers?

A. p ^ q
B. p & q
C. p | q
D. All of above
E. None of these
Answer» F.
13.

What is the size of *p in a 32-bit machine (Assuming initialization as int *p = 12;)?

A. 8
B. 4
C. 2
D. 1
E. None of these
Answer» C. 2
14.

Which of the following arithmetic operation can be applied to pointers p and q?

A. p / q
B. p + q
C. p q
D. p * q
E. None of these
Answer» D. p * q
15.

What are the elements present in the array of the following C code?

A. 10, 10, 10, 10
B. 0, 0, 0, 0
C. 10, 0, 0, 0
D. 0, garbage value, garbage value, garbage value
E. 10, garbage value, garbage value, garbage value
Answer» D. 0, garbage value, garbage value, garbage value
16.

What type of initialization is needed for the segment p[3] = 3 ; to work?

A. int *p= "Interview",
B. char *p = Interview! ;
C. char p[] = Interview! ;
D. both char *p = Interview! ; and char p[] = Interview! ;
E. None of these
Answer» D. both char *p = Interview! ; and char p[] = Interview! ;
17.

What substitution should be made to //-Reference such that p1 points to variable t3 in the following C code?

A. **p2 = &t3;
B. *p1 = &t3;
C. *p2 = &t3;
D. All of above
E. None of these
Answer» D. All of above
18.

An array of strings can be initialized by _________.

A. <pre class="prettyprint lang-c">char *ch1 = "Interview";<br>char *ch2 = "Mania";<br>char *ch3[] = {ch1, ch2};<br></pre>
B. char *ch[] = { Interview , Mania };
C. char *a[] = { Interview , Mania };
D. All of above
E. None of these
Answer» E. None of these
19.

What is the correct way to declare and assign a function pointer?

A. int *fn_ptr(int, int) = multi;
B. int *fn_ptr(int, int) = &multi;
C. int (*fn_ptr)(int, int) = multi;
D. All of above
E. None of these
Answer» D. All of above
20.

Calling a function fun with num an array variable num[3] where num is an array, is equivalent to __________.

A. fun(3[num])
B. fun(num[3])
C. fun(*(num + 3))
D. All of above
E. None of these
Answer» E. None of these
21.

An array of similar data types which themselves are a collection of dissimilar data type are ___________.

A. Trees
B. Array of Structure
C. Linked Lists
D. All of above
E. None of these
Answer» C. Linked Lists
22.

Comment on the following pointer declaration.

A. p and n both are not pointers to integer
B. p is a pointer to integer, n may or may not be
C. p and n, both are pointers to integer
D. p is a pointer to integer, n is not
E. None of these
Answer» E. None of these
23.

Which of the following does not initialize p to null (assuming variable declaration of n as int n=0;)?

A. int *p = &n &n;
B. int *p = n n;
C. int *p = &n;
D. All of above
E. None of these
Answer» D. All of above