c programming banner

C Programming Multiple Choice Questions (MCQs) and Answers

Master C Programming with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of C Programming. Begin your placement preparation journey now!

Q61

Q61 What will be the output of the following C code?
int main() {
int num = 10;
increment(num);
printf("%d", num);
return 0;
} void increment(int n) {
n++;
}

A

10

B

11

C

Error

D

Nothing

Q62

Q62 What is the output of this recursive function call?
int main() {
printf("%d ", factorial(5));
return 0;
}
int factorial(int n) {
if (n==0)
return 1;
else
return n * factorial(n - 1);
}

A

120

B

24

C

5

D

Error

Q63

Q63 Pseudocode:

FUNCTION Add(a, b) RETURN a PLUS b END FUNCTION CALL Add(5, 10)

A

15

B

5

C

10

D

Error

Q64

Q64 Pseudocode:

FUNCTION CheckEven(number) IF number MOD 2 EQUALS 0 THEN RETURN True ELSE RETURN False END FUNCTION CALL CheckEven(4)

A

True

B

False

C

Error

D

None

Q65

Q65 Pseudocode:

FUNCTION Fibonacci(n) IF n LESS THAN OR EQUAL TO 1 THEN RETURN n ELSE RETURN Fibonacci(n-1) PLUS Fibonacci(n-2) END FUNCTION CALL Fibonacci(5)

A

5

B

8

C

Error

D

None

Q66

Q66 Identify the error in this C code:
int main() {
printHello();
return 0;
}
void printHello() {
printf("Hello");
}

A

Missing declaration of printHello

B

Syntax error

C

No error

D

Wrong function call

Q67

Q67 Spot the mistake:
int main() {
int result = sum(5, 10);
printf("%d", result);
return 0;
}
int sum(int a, int b) {
return;
}

A

Missing return value in sum

B

Syntax error

C

No error

D

Incorrect function parameters

Q68

Q68 Find the error:

int main() {
int x = 5;
increment(&x);
printf("%d", x);
return 0;
}
void increment(int* n) {
*n++;
}

A

Incorrect pointer usage in increment

B

Syntax error

C

No error

D

Wrong printf format

Q69

Q69 How do you declare an array of integers in C?

A

int arr[10];

B

array int[10];

C

int array 10;

D

[10]int array;

Q70

Q70 Which index is used to access the first element of an array in C?

A

0

B

1

C

-1

D

First

Q71

Q71 What happens when you try to access an array element outside its bounds in C?

A

Syntax error

B

Compilation error

C

Runtime error

D

Undefined behavior

Q72

Q72 How do you initialize an array in C?

A

With any value

B

With 0s

C

With 1s

D

Cannot be initialized

Q73

Q73 Which of the following is a correct way to pass an array to a function in C?

A

By specifying the size of the array

B

By passing the first element

C

By passing the array name

D

By passing each element individually

Q74

Q74 What is the size of a 2-dimensional array int arr[3][4]; in C?

A

3

B

4

C

12

D

Cannot be determined

Q75

Q75 How can you access the third element in the second row of a 2D array int arr[3][4]; in C?

A

arr[1][2]

B

arr[2][3]

C

arr[3][2]

D

arr[2][1]

Q76

Q76 What is the default value of an uninitialized array in C?

A

0

B

1

C

Random memory value

D

-1

Q77

Q77 How does C handle array index out of bounds errors during runtime?

A

Generates a compile-time error

B

Automatically corrects the index

C

Generates a runtime error

D

Does not check for bounds

Q78

Q78 In C, can an array be resized after its declaration?

A

Yes

B

No

C

Only if it's a dynamic array

D

Only in C99 standard

Q79

Q79 What will be the output of the following C code?
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d", arr[3]);
return 0;
}

A

1

B

2

C

3

D

4

Q80

Q80 What is the output of this C code?
int main() {
int arr[5] = {1, 2, 3};
printf("%d", arr[4]);
return 0;
}

A

0

B

3

C

Random value

D

Error

Q81

Q81 What does the following C code do?
int main() {
int arr[3][4] = {{1, 2}, {3, 4}};
printf("%d", arr[1][1]);
return 0;
}

A

Prints 2

B

Prints 3

C

Prints 4

D

Prints 0

Q82

Q82 Complete the C code:
int main() {
int arr[5];
for(int i = 0; i < 5; i++) { ___ }
printf("%d", arr[2]);
return 0;
}

A

arr[i] = i;

B

arr[i] = i * 2;

C

arr[i] = i + 1;

D

arr[i] = 0;

Q83

Q83 Pseudocode:

ARRAY numbers[5] SET numbers[0] TO 1 PRINT numbers[0]

A

Prints 1

B

Prints 0

C

Prints random value

D

Syntax error

Q84

Q84 Pseudocode:

ARRAY arr[10] FOR i FROM 0 TO 9 SET arr[i] TO i TIMES 2 END FOR PRINT arr[6]

A

Prints 6

B

Prints 12

C

Prints 7

D

Syntax error

Q85

Q85 Pseudocode:

FUNCTION SumArray(ARRAY arr, SIZE) SET sum TO 0 FOR i FROM 0 TO SIZE-1 INCREMENT sum BY arr[i] RETURN sum

A

Calculates the sum of array elements

B

Returns the size of the array

C

Returns the first element

D

Syntax error

Q86

Q86 Pseudocode:

ARRAY matrix[2][3] SET matrix[0][0] TO 1, matrix[0][1] TO 2, matrix[0][2] TO 3, matrix[1][0] TO 4, matrix[1][1] TO 5, matrix[1][2] TO 6 PRINT matrix[1][2]

A

Prints 1

B

Prints 5

C

Prints 6

D

Syntax error

Q87

Q87 Identify the error in this C code:
int main() {
int arr[3];
arr[3] = 10;
printf("%d", arr[3]);
return 0;
}

A

Array index out of bounds

B

Syntax error

C

No error

D

Wrong printf format

Q88

Q88 Find the mistake:
int main() {
int arr[5] = {1, 2, 3, 4, 5};
for(int i = 0; i <= 5; i++) {
printf("%d ", arr[i]);
}
return 0;
}

A

Off-by-one error in loop bounds

B

Syntax error

C

No error

D

Incorrect array initialization

Q89

Q89 What is a pointer in C?

A

A variable that stores a memory address

B

A function

C

An array

D

A data type

Q90

Q90 What is the output of sizeof(pointer) where pointer is an integer pointer in C?

A

4 on all systems

B

8 on all systems

C

Depends on the system architecture

D

Depends on the compiler

ad verticalad vertical
ad