Explore topic-wise MCQs in C Programming.

This section includes 93 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 program in Turbo-C ?

A. 1, 2, 3, 4, 5,
B. -1, 0, 1, 2, 3, 4
C. 0, 1, 2, 3, 4,
D. 0, -1, -2, -3, -4,
Answer» D. 0, -1, -2, -3, -4,
2.

Which of the following statements mentioning the name of the array begins DOES NOT yield the base address?

A. A
B. A, B
C. B
D. B, D
Answer» C. B
3.

Which of the following statements are correct about 6 used in the program?

A. In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type.
B. In the first statement 6 specifies a array size, whereas in the second statement it specifies a particular element of array.
C. In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size.
D. In both the statement 6 specifies array size.
Answer» C. In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size.
4.

Which of the following statements are correct about an array?

A. 1
B. 1,4
C. 2,3
D. 2,4
Answer» C. 2,3
5.

Are the expressions and same for an array of 10 integers?

A. Yes
B. No
Answer» C.
6.

Is there any difference int the following declarations?

A. Yes
B. No
Answer» C.
7.

What does the following declaration mean?

A. is array of pointers to 10 integers
B. is a pointer to an array of 10 integers
C. is an array of 10 integers
D. is an pointer to array
Answer» C. is an array of 10 integers
8.

Which of the following is the correct output for the program given below?
#include
int main()
{
int arr[5] = {12, 23);
printf("%d%d%d n", a[2], a[3], a[4]);
return 0;
}

A. Garbage values
B. 2 3 3
C. 3 2 2
D. 0 0 0
Answer» E.
9.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num[3][4][5], k = 12;
num[0][0] = &k;
printf("%d n", *num[0][0]);
}

A. Address of k
B. Compilation Error
C. Undefined behaviour
D. 12
E. None of these
Answer» C. Undefined behaviour
10.

Which of the following statements are correct about 4 used in the following C expressions?
int num[4] ;
num[4] = 23 ;

A. In the first statement 4 specifies a particular element, whereas in the second statement it specifies a type.
B. In the first statement 4 specifies the array size, whereas in the second statement it specifies a particular element of the array.
C. In the first statement 4 specifies a particular element, whereas in the second statement it specifies the array size.
D. In both the statement 4 specifies array size.
E. In the first statement 4 specifies array size, whereas in the second statement it specifies that the array size be increased from 4 to 23.
Answer» C. In the first statement 4 specifies a particular element, whereas in the second statement it specifies the array size.
11.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int Array[2][5];
Array[][] = {{10, 20, 30, 40, 50}, {40, 50, 60, 70, 80}};
printf("%d n", Array[3][4]);
}

A. Garbage value
B. Compilation Error
C. 30 70
D. Undefined behaviour
E. None of these
Answer» C. 30 70
12.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
N(num);
}
void N(int **num)
{
int n1 = 15, n2 = 15, n3 = 12;
int *num[2];
num[0] = &n1;
num[1] = &n2;
printf("%d n", num[0][1]);
}

A. 15
B. Undefined behaviour
C. Compilation Error
D. Garbage value
E. None of these
Answer» D. Garbage value
13.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num[4][5];
f(num);
}
void f(int (*num)[4])
{
int n1 = 15, n2 = 13, n;
num[0] = &n1;
num[1] = &n2;
for (n = 0; n < 2; n++)
printf("%d n", *num[n]);
}

A. Compilation Error
B. Garbage value
C. Undefined behaviour
D. Compilation Error
E. segmentation fault/code crash
Answer» E. segmentation fault/code crash
14.

What will be the output of the following C code?
#include <stdio.h>
void fun(int number[][3])
{
number[0][1] = 15;
int k = 0, L = 0;
for (k = 0; k < 2; k++)
for (L = 0; L < 3; L++)
printf("%d ", number[k][L]);
}
void main()
{
int number[2][3] = {0};
fun(number);
}

A. 0 15 0 0 0 Garbage value
B. Runtime Error
C. Compilation Error
D. Only garbage value
E. 0 15 0 0 0 0
Answer» F.
15.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int array[2][3] = {10, 20, 30, 40, 50};
int k = 0, L = 0;
for (k = 0; k < 2; k++)
for (L = 0; L < 3; L++)
printf("%d ", array[k][L]);
}

A. 10 20 30 40 50
B. Compilation Error
C. Garbage value
D. 10 20 30 40 50 0
E. None of these
Answer» E. None of these
16.

Comment on the following C statement.
int (*num)[12];

A. A pointer num to an array
B. A ragged array
C. An array num of pointers
D. All of above
E. None of these
Answer» B. A ragged array
17.

What will be the output of the following C code?
#include 
void f(int n[5][])
{
n[0][4] = 11;
int k = 0, L = 0;
for (k = 0; k < 4; k++)
for (L = 0; L < 5; L++)
printf("%d", n[k][L]);
}
void main()
{
int n[4][5] = {0};
f(n);
}

A. Garbage value Garbage value 11 Garbage value Garbage value
B. Only garbage value
C. Runtime Error
D. 11
E. Compilation Error
Answer» F.
18.

What will be the output of the following C code?
 #include <stdio.h>
void function(int number[][])
{
number[0][1] = 12;
int k = 0, L = 0;
for (k = 0; k < 2; k++)
for (L = 0; L < 3; L++)
printf("%d", number[k][L]);
}
void main()
{
int number[2][3] = {0};
function(number);
}

A. 0 12 0 0 0 0
B. Garbage value 12 Garbage value Garbage value Garbage value
C. Runtime Error
D. Compilation Error
E. None of these
Answer» E. None of these
19.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int Array[2][3] = {11, 21, 31, , 41, 51};
int k = 0, L = 0;
for (k = 0; k < 2; k++)
for (L = 0; L < 3; L++)
printf("%d", Array[k][L]);
}

A. 11 21 31 Garbage value 41 51
B. 11 21 31 41 15
C. Compilation Error
D. Runtime Error
E. None of these
Answer» D. Runtime Error
20.

Comment on the following 2 arrays with respect to I and II.
 int *num1[10];
int *(num2[10]);
I. Array of pointers
II. Pointer to an array

A. num1 is II, num2 is I
B. num1 is I, num2 is II
C. num1 is II, num2 is II
D. num1 is I, num2 is I
E. None of these
Answer» E. None of these
21.

Which of the following are the correct ways to define an array of 2 rows and 3 columns? int[ , ] a; a = new int[2, 3]{{7, 1, 3},{2, 9, 6}}; int[ , ] a; a = new int[2, 3]{}; int[ , ] a = {{7, 1, 3}, {2, 9,6 }}; int[ , ] a; a = new int[1, 2]; int[ , ] a; a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

A. 1, 2 , 3
B. 1, 3
C. 2, 3
D. 2, 4, 5
E. 4, 5
Answer» C. 2, 3
22.

Which of the following statements are correct about arrays used in C#.NET? Arrays can be rectangular or jagged. Rectangular arrays have similar rows stored in adjacent memory locations. Jagged arrays do not have an access to the methods of System.Array Class. Rectangular arrays do not have an access to the methods of System.Array Class. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

A. 1, 2
B. 1, 3, 5
C. 3, 4
D. 1, 2, 5
E. 4, 5
Answer» E. 4, 5
23.

Which of the following is the correct way to define and initialise an array of 4 integers? int[] a = {25, 30, 40, 5}; int[] a; a = new int[3]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5; int[] a; a = new int{25, 30, 40, 5}; int[] a; a = new int[4]{25, 30, 40, 5}; int[] a; a = new int[4]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5;

A. 1, 2
B. 3, 4
C. 1, 4, 5
D. 2, 4, 5
E. 2, 5
Answer» D. 2, 4, 5
24.

Which of the following is the correct way to obtain the number of elements present in the array given below? int[] intMyArr = {25, 30, 45, 15, 60};intMyArr.GetMax; intMyArr.Highest(0); intMyArr.GetUpperBound(0); intMyArr.Length; intMyArr.GetMaxElements(0);

A. 1, 2
B. 3, 4
C. 3, 5
D. 1, 5
E. 4, 5
Answer» C. 3, 5
25.

Which of the following statements are correct about the C#.NET code snippet given below? int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};intMyArr represents rectangular array of 2 rows and 3 columns. intMyArr.GetUpperBound(1) will yield 2. intMyArr.Length will yield 24. intMyArr represents 1-D array of 5 integers. intMyArr.GetUpperBound(0) will yield 2.

A. 1, 2
B. 2, 3
C. 2, 5
D. 1, 4
E. 3, 4
Answer» B. 2, 3
26.

Which of the following statements are correct about the C#.NET code snippet given below? int[] a = {11, 3, 5, 9, 4}; The array elements are created on the stack. Refernce a is created on the stack. The array elements are created on the heap. On declaring the array a new array class is created which is derived from System.Array Class. Whether the array elements are stored in the stack or heap depends upon the size of the array.

A. 1, 2
B. 2, 3, 4
C. 2, 3, 5
D. 4, 5
E. None of these
Answer» C. 2, 3, 5
27.

Which of the following statements is correct about the C#.NET code snippet given below? int[] intMyArr = {11, 3, 5, 9, 4};

A. intMyArr is a reference to an object of System.Array Class.
B. intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.
C. intMyArr is a reference to an array of integers.
D. intMyArr is a reference to an object created on the stack.
E. intMyArr is a reference to the array created on the stack.
Answer» C. intMyArr is a reference to an array of integers.
28.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ void fun(int, int[]);_x000D_ int arr[] = {1, 2, 3, 4};_x000D_ int i;_x000D_ fun(4, arr);_x000D_ for(i=0; i<4; i++)_x000D_ printf("%d,", arr[i]);_x000D_ return 0;_x000D_ }_x000D_ void fun(int n, int arr[])_x000D_ {_x000D_ int *p=0;_x000D_ int i=0;_x000D_ while(i++ < n)_x000D_ p = &arr[i];_x000D_ *p=0;_x000D_ }

A. 2, 3, 4, 5
B. 1, 2, 3, 4
C. 0, 1, 2, 3
D. 3, 2, 1 0
Answer» C. 0, 1, 2, 3
29.

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};_x000D_ printf("%u, %u\n", a+1, &a+1);_x000D_ return 0;_x000D_ }

A. 65474, 65476
B. 65480, 65496
C. 65480, 65488
D. 65474, 65488
Answer» C. 65480, 65488
30.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ float arr[] = {12.4, 2.3, 4.5, 6.7};_x000D_ printf("%d\n", sizeof(arr)/sizeof(arr[0]));_x000D_ return 0;_x000D_ }

A. 5
B. 4
C. 6
D. 7
Answer» C. 6
31.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ static int arr[] = {0, 1, 2, 3, 4};_x000D_ int *p[] = {arr, arr+1, arr+2, arr+3, arr+4};_x000D_ int **ptr=p;_x000D_ ptr++;_x000D_ printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);_x000D_ *ptr++;_x000D_ printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);_x000D_ *++ptr;_x000D_ printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);_x000D_ ++*ptr;_x000D_ printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr);_x000D_ return 0;_x000D_ }

A. 0, 0, 01, 1, 12, 2, 23, 3, 3
B. 1, 1, 22, 2, 33, 3, 44, 4, 1
C. 1, 1, 12, 2, 23, 3, 33, 4, 4
D. 0, 1, 21, 2, 32, 3, 43, 4, 5
Answer» D. 0, 1, 21, 2, 32, 3, 43, 4, 5
32.

What will be the output of the program if the array begins at address 65486?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int arr[] = {12, 14, 15, 23, 45};_x000D_ printf("%u, %u\n", arr, &arr);_x000D_ return 0;_x000D_ }

A. 65486, 65488
B. 65486, 65486
C. 65486, 65490
D. 65486, 65487
Answer» C. 65486, 65490
33.

What will be the output of the program if the array begins 1200 in memory?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int arr[]={2, 3, 4, 1, 6};_x000D_ printf("%u, %u, %u\n", arr, &arr[0], &arr);_x000D_ return 0;_x000D_ }

A. 1200, 1202, 1204
B. 1200, 1200, 1200
C. 1200, 1204, 1208
D. 1200, 1202, 1200
Answer» C. 1200, 1204, 1208
34.

Each element in an array has an index and the starting index is index 1.

A. True
B. False
Answer» C.
35.

What will be output of the given code?

A. [1, 2, 3, 4].
B. 1234
C. Error
D. None of the mentionedView Answer
Answer» B. 1234
36.

Arrays can be used to store multiple values in one single variable.

A. True
B. False
Answer» B. False
37.

While mentioning the array size in a multidimensional array using the new keyword, the left-most script is mandatory. State TRUE or FALSE.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
38.

State TRUE or FALSE. In a multidimensional array, the number of Columns in each Row can be different.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
39.

What is the output of the Java program with the multidimensional array?

A. 0
B. 1
C. 2
D. Compiler error
Answer» E.
40.

Choose the correct way of initializing a multidimensional array below.

A. int[][] code = {{1,2},{3,4,5}};
B. int[2][] code = {{1,2},{3,4,5}};
C. int[][] code={1,2,
D. All
Answer» B. int[2][] code = {{1,2},{3,4,5}};
41.

A 4-dimensional array is an array of ___ dimensional arrays.

A. 4
B. 3
C. 2
D. 1
Answer» C. 2
42.

Row number and Column number in a Multidimensional array start with ___.

A. -1
B. 0
C. 1
D. 2
Answer» C. 1
43.

An array with two dimensions is called a two-dimensional array in Java. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
44.

An array of dimension N contains __ number of subscripts or brackets?

A. N-1
B. N
C. N+1
D. 10*N
Answer» C. N+1
45.

A multidimensional array contains elements of the same data-type in all rows and columns. State TRUE or FALSE.

A. FALSE
B. TRUE
C. -
D. -
Answer» D. -
46.

An array of arrays in Java is called ___ array.

A. Bidirectional
B. Combo
C. Multidimensional
D. Multi-value
Answer» D. Multi-value
47.

Allocating memory with the keyword "new" causes the array elements to carry default values. State TRUE or FALSE.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
48.

What is the default value of boolean data type elements of an array in Java?

A. true
B. false
C. -
D. -
Answer» C. -
49.

What is the default value of a char data type elements of an array in Java?

A. 'A'
B. '\0'
C. null
D. '\0' or null
Answer» E.
50.

What is the default value of float or double data type elements of an array in Java?

A. 0
B. 0.0
C. 1
D. 1.0
Answer» C. 1