Home Programming Kids Programming Hardware & Software Hardware & Networking APP security Software Education Kids Study MCQS Download OTHERS Multiple Choice Question (MCQ) Multiple Choice Question (MCQ) Login

C Programming Multiple Choice Question MCQ

Categories: Programming

Q1. Identify the error in this C code:

int main() {

int x;

scanf("%d", x);

printf("%d", x);

return 0;

}


(A) Missing & in scanf

(B) Wrong format specifier

(C) No error

(D) Syntax error



Answer: A


Q2. Find the mistake in this code:

int main() {

float num;

printf("Enter a number: ");

scanf("%f", num);

printf("You entered: %f", num);

return 0;

}


(A) Missing & in scanf

(B) Incorrect format specifier in printf

(C) No error

(D) Syntax error


Answer: A


Q3. Which operator is used for division in C?

(A) -

(B) *

(C) /

(D) =+


Answer: C


Q4. What does the '==' operator check?

(A) Assignment

(B) Equality

(C) Greater than

(D) Less than


Answer: B


Q5. What is the result of the logical expression (1 && 0)?

(A) 1

(B) 0

(C) True

(D) False


Answer: B


Q6. What does the '+' operator do in C?

(A) Addition

(B) Subtraction

(C) Multiplication

(D) Division


Answer: A


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

(A) *

(B) Both are same

(C) =+

(D) None


Answer: *


Q8. What does the '!' operator do in C?

(A) Negation

(B) Addition

(C) Multiplication

(D) None


Answer: A


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

(A) 0

(B) 1

(C) 2

(D) 3


Answer: B


Q10 What will be the output of the following C code?

int main() {

int a = 10, b = 5;

printf("%d", a / b);

return 0;

}


(A) 2

(B) 5

(C) 0

(D) 10


Answer: 2


Q11. What is the output of the following C code snippet?

int main() {

int x

= 10;

printf("%d", x++ + ++x);

return 0;

}


(A) 20

(B) 21

(C) 22

(D) 23


Answer: C


Q12 What is the result of the following expression?

int a = 1; int b = a++ + ++a;

(A) 2

(B) 3

(C) 4

(D) 5


Answer: C

Q13 Pseudocode:

SET x TO 5, y TO 10 IF x LESS THAN y THEN PRINT "x is less than y" ELSE PRINT "x is not less than y"

(A) Prints "x is less than y"

(B) Prints "x is not less than y"

(C) Prints nothing

(D) Syntax error


Answer: A


Q14 Pseudocode:

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

(A) 30

(B) 20

(C) 10

(D) 0


Answer: 30


Q15 Pseudocode:

SET num TO 5 IF num EQUALS 5 THEN PRINT "Five" ELSE PRINT "Not Five"

(A) Prints "Five"

(B) Prints "Not Five"

(C) Prints nothing

(D) Syntax error


Answer: A


Q16 Pseudocode:

SET value TO 10 PRINT NOT value

(A) -10

(B) 0

(C) 1

(D) 10


Answer: B


Q17 Pseudocode:

SET a TO 10, b TO 20 IF a GREATER THAN b THEN PRINT "a is greater" ELSE PRINT "b is greater or equal"

(A) Prints "a is greater"

(B) Prints "b is greater or equal"

(C) Prints nothing

(D) Syntax error


Answer: B


Q18 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"


Answer: D


Q19 Pseudocode:

SET c TO 15 IF c MOD 2 EQUALS 0 THEN PRINT "Even" ELSE PRINT "Odd"

(A) Prints "Even"

(B) Prints "Odd"

(C) Prints nothing

(D) Syntax error


Answer: B


Q20 Spot the error:

int main() {

int a = 10, b = 0;

printf("%d", a / b);

return 0;

}

(A) Division by zero

(B) Syntax error

(C) No error

(D) Wrong format specifier


Answer: A


C Programming Multiple Choice Question MCQ