an HCL GUVI product

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!

Q91

Q91 Which operator has higher precedence, '+' or '*'?

A

*

B

Both are same

C

=+

D

None

Q92

Q92 What is the output of the expression 2<3?

A

0

B

1

C

2

D

3

Q93

Q93 Pseudocode:

SET a TO 10, b TO 20 PRINT a PLUS b

A

30

B

20

C

10

D

0

Q94

Q94 Pseudocode:

SET value TO 10 PRINT NOT value

A

-10

B

0

C

1

D

10

Q95

Q95 Pseudocode:

SET x TO 5 IF x GREATER THAN 0 AND x LESS THAN 10 THEN PRINT "x is between 0 and 10"

A

Prints "x is between 0 and 10"

B

Prints nothing

C

Syntax error

D

Prints "x is not between 0 and 10"

Q96

Q96 Identify the mistake:
int main() {
int x = 10, y; y = x == 10 ? x : 0;
printf("%d", y);
return 0;
}

A

Incorrect use of ternary operator

B

Syntax error

C

No error

D

Wrong variable used

Q97

Q97 What is the difference between for and while loops?

A

Syntax

B

Execution speed

C

Functionality

D

No difference

Q98

Q98 What is the output of the following C code?
int main() {
int x = 0; do {
printf("%d ", x);
x++;
} while(x < 3);
return 0;
}

A

0 1 2

B

0 1

C

1 2 3

D

No output

Q99

Q99 Pseudocode:

SET count TO 0 REPEAT PRINT count INCREMENT count UNTIL count EQUALS 3

A

Prints 0 1 2 3

B

Prints 0 1 2

C

Prints 3

D

Syntax error

Q100

Q100 Pseudocode:

SET i TO 0 WHILE i LESS THAN 10 IF i MOD 2 EQUALS 0 THEN CONTINUE INCREMENT i PRINT i END WHILE

A

Prints odd numbers from 1 to 9

B

Prints even numbers from 0 to 8

C

Prints all numbers from 0 to 9

D

Syntax error

Q101

Q101 Spot the mistake:
int main() {
for(int i = 0; i < 5; i++) {
if(i == 2)
continue;
printf("%d ", i);
} return 0;
}

A

Infinite loop

B

Skips printing 2

C

Syntax error

D

No error

Q102

Q102 What does 'pass by value' mean in C?

A

Passing a copy of the argument

B

Passing the argument directly

C

Passing the memory address

D

Passing the variable type

Q103

Q103 What is the scope of a local variable in C?

A

Inside the function in which it is declared

B

Throughout the program

C

Inside the file

D

Throughout the function block where it is declared

Q104

Q104 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

Q105

Q105 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

Q106

Q106 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

Q107

Q107 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

Q108

Q108 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

Q109

Q109 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

Q110

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

A

0

B

1

C

-1

D

First

Q111

Q111 How do you initialize an array in C?

A

With any value

B

With 0s

C

With 1s

D

Cannot be initialized

Q112

Q112 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

Q113

Q113 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]

Q114

Q114 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

Q115

Q115 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;

Q116

Q116 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

Q117

Q117 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

Q118

Q118 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

Q119

Q119 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

Q120

Q120 What does passing a pointer to a function allow the function to do?

A

Read the value of the variable

B

Change the value of the variable

C

Copy the variable

D

None of the above

ad vertical