MCQ on C Language with Answers: Welcome to our blog post on “The Best 50 MCQ on C Language with Answers”! This 50 MCQ on C will assess your understanding of the C Programming Language. It will help both beginner, intermediate and experienced programmers aiming to test their knowledge. These MCQs will help you to pass BCA, BTech, or any other competitive examination. To get benefits from these 50 MCQ on C Language with Answers, you must try the MCQ options first. And see the answer below after 50 MCQ as well as “View Answer”.
MCQ on C Language with Answers: MCQ on C
1. Which of the following is not a valid data type in C Language?
a) int
b) float
c) real
d) char
2. Which operator is used to access the value at a specific memory address?
a) &
b) *
c) $
d) %
3. What is the result of the expression 6 + 4 / 2 * 3 – 1?
a) 10
b) 12
c) 15
d) 11
4. What is the correct way to declare an array in C Language?
a) int array[];
b) int array[10];
c) array[] = {1, 2, 3};
d) array[10] = {1, 2, 3};
5. What is the output of the following code snippet?
int x = 5;
printf(“%d”, ++x);
a) 4
b) 5
c) 6
d) 10
6. What is the purpose of the size operator in C?
a) It determines the size of objects
b) It returns the address of a variable.
c) It returns the ASCII value of a character.
d) It returns the value of a variable.
7. What is the output of the following code snippet?
int x = 10;
printf(“%d”, x++);
a) 9
b) 10
c) 11
d) 12
8. Which loop construct is used for executing a block of code repeatedly until a condition is satisfied?
a) for
b) while
c) do-while
d) if-else
9. What is the correct way to define a constant in C Language?
a) #define CONSTANT 10
b) const CONSTANT = 10;
c) constant CONSTANT = 10;
d) constant = 10;
10. What is the output of the following code snippet?
int x = 5;
printf(“%d”, x–);
a) 4
b) 5
c) 6
d) 10
11. What is the purpose of the “break” statement in C Language?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current function and returns a value.
12. Which header file is required to use the printf and scanf functions in C?
a) stdlib.h
b) string.h
c) math.h
d) stdio.h
13. What is the output of the following code snippet?
int x = 5;
printf(“%d”, x++);
printf(“%d”, x);
a) 5, 5
b) 5, 6
c) 6, 5
d) 6, 6
14. What is the purpose of the “continue” statement in C Language?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current function and returns a value.
15. What is the output of the following code snippet?
int x = 2;
int y = 4;
printf(“%d”, x << y);
a) 2
b) 4
c) 32
d) 16
16. What is the purpose of the “else” statement in an if-else construct?
a) It is used to specify the condition for the if statement.
b) It is used to specify the block of code to be executed if the condition in the if statement is true.
c) It is used to specify the block of code to be executed if the condition in the if statement is false.
d) It is used to specify the block of code to be executed in all cases.
17. Which of the following is a valid way to declare a pointer in C Language?
a) int *ptr;
b) *int ptr;
c) ptr int *;
d) pointer int;
17. What is the output of the following code snippet?
int x = 10;
int y = (x > 5) ? 2 : 1;
printf(“%d”, y);
a) 2
b) 1
c) 10
d) 5
19. Which of the following is not a logical operator in C Language?
a) &&
b) ||
c) !
d) ^^
20. What is the output of the following code snippet?
int x = 5;
int y = sizeof(++x);
printf(“%d”, x);
a) 4
b) 5
c) 6
d) 10
21. What is the purpose of the “return” statement in C Language?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current function and returns a value.
22. Which of the following is not a valid way to define a string in C Language?
a) char str[] = “Hello”;
b) char *str = “Hello”;
c) char str[6] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘\0’};
d) char str[6] = “Hello”;
23. What is the output of the following code snippet?
int x = 5;
int y = x + 2 * 3;
printf(“%d”, y);
a) 5
b) 11
c) 15
d) 23
Read More
The Best 50 MCQ On Python Language With Answers
Best 50 Java Multiple-Choice Questions To Test Your Skills, And Boost Your Knowledge
The Best 50 Java Interview Questions With Answers
60 Python Interview Questions Answers
24. What is the purpose of the “&&” operator in C Language?
a) It performs logical AND operation between two operands.
b) It performs logical OR operation between two operands.
c) It performs bitwise AND operation between two operands.
d) It performs bitwise OR operation between two operands.
25. What is the output of the following code snippet?
int x = 10;
if (x > 5 && x < 15)
printf(“True”);
else
printf(“False”);
a) True
b) False
c) Error
d) No output
26. What is the purpose of the “||” operator in C Language?
a) It performs logical AND operation between two operands.
b) It performs logical OR operation between two operands.
c) It performs bitwise AND operation between two operands.
d) It performs bitwise OR operation between two operands.
27. What is the output of the following code snippet?
int x = 10;
if (x > 5 || x < 15)
printf(“True”);
else
printf(“False”);
a) True
b) False
c) Error
d) No output
28. What is the purpose of the “!” operator in C Language?
a) It negates the value of a variable.
b) It performs logical AND operation between two operands.
c) It performs logical OR operation between two operands.
d) It performs bitwise XOR operation between two operands.
29. What is the output of the following code snippet?
int x = 5;
if (!(x > 10))
printf(“True”);
else
printf(“False”);
a) True
b) False
c) Error
d) No output
30. What is the purpose of the “switch” statement in C Language?
a) It is used to specify the condition for the if statement.
b) It is used to specify the block of code to be executed if the condition in the if statement is true.
c) It is used to specify the block of code to be executed if none of the cases match.
d) It is used to specify the block of code to be executed based on the value of an expression.
31. What is the output of the following code snippet?
int x = 2;
switch (x)
{
case 1:
printf(“One”);
break;
case 2:
printf(“Two”);
break;
default:
printf(“Default”);
break;
}
a) One
b) Two
c) Default
d) Error
32. What is the purpose of the “break” statement in a switch statement?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current switch statement and transfers control to the statement after the switch.
33. What is the output of the following code snippet?
int i = 0;
while (i < 5)
{
printf(“%d”, i);
i++;
}
a) 0 1 2 3 4
b) 1 2 3 4 5
c) 0 1 2 3 4 5
d) 1 2 3 4
34. What is the purpose of the “do-while” loop in C Language?
a) It is used to execute a block of code repeatedly until a condition is satisfied.
b) It is used to execute a block of code at least once, and then repeatedly until a condition is satisfied.
c) It is used to execute a block of code based on the value of an expression.
d) It is used to execute a block of code based on the value of a variable.
35. What is the output of the following code snippet?
int i = 0;
do
{
printf(“%d”, i);
i++;
} while (i < 5);
a) 0 1 2 3 4
b) 1 2 3 4 5
c) 0 1 2 3 4 5
d) 1 2 3 4
36. What is the purpose of the “for” loop in C Language?
a) It is used to execute a block of code repeatedly until a condition is satisfied.
b) It is used to execute a block of code at least once, and then repeatedly until a condition is satisfied.
c) It is used to execute a block of code based on the value of an expression.
d) It is used to execute a block of code based on the value of a variable.
37. What is the output of the following code snippet?
for (int i = 0; i < 5; i++)
{
printf(“%d”, i);
}
a) 0 1 2 3 4
b) 1 2 3 4 5
c) 0 1 2 3 4 5
d) 1 2 3 4
38. What is the purpose of the “continue” statement in a loop construct?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current function and returns a value.
39. What is the output of the following code snippet?
for (int i = 0; i < 5; i++)
{
if (i == 2)
continue;
printf(“%d”, i);
}
a) 0 1 2 3 4
b) 1 2 3 4 5
c) 0 1 3 4
d) 1 3 4
40. What is the purpose of the “goto” statement in C Language?
a) It terminates the current loop and transfers control to the next iteration.
b) It transfers control to a specified label within the current function.
c) It skips the remaining statements in a loop and continues with the next iteration.
d) It exits the current function and returns a value.
41. What is the output of the following code snippet?
for (int i = 0; i < 5; i++)
{
if (i == 2)
goto end;
printf(“%d”, i);
}
end:
printf(“End”);
a) 0 1 2 End
b) 1 2 End
c) 0 1 2 3 4 End
d) 1 3 4 End
42. What is the purpose of the “typedef” keyword in C Language?
a) It is used to define a new data type.
b) It is used to declare a variable.
c) It is used to define a constant.
d) It is used to include a header file.
43. What is the output of the following code snippet?
typedef int myInt;
myInt x = 5;
printf(“%d”, x);
a) 4
b) 5
c) 6
d) 10
44. What is the purpose of the “struct” keyword in C Language?
a) It is used to define a new data type.
b) It is used to declare a variable.
c) It is used to define a constant.
d) It is used to include a header file.
45. What is the output of the following code snippet?
struct student
{
char name[20];
int age;
};
struct student s;
s.age = 20;
printf(“%d”, s.age);
a) 10
b) 20
c) 30
d) Error
46. What is the purpose of the “->” operator in C Language?
a) It is used to access the value at a specific memory address.
b) It is used to perform logical AND operations between two operands.
c) It is used to perform logical OR operations between two operands.
d) It is used to access the members of a structure through a pointer.
47. What is the output of the following code snippet?
struct student
{
char name[20];
int age;
};
struct student s;
struct student *ptr = &s;
ptr->age = 20;
printf(“%d”, ptr->age);
a) 10
b) 20
c) 30
d) Error
48. What is the purpose of the “enum” keyword in C Language?
a) It is used to define a new data type.
b) It is used to declare a variable.
c) It is used to define a constant.
d) It is used to include a header file.
49. What is the output of the following code snippet?
enum color
{
RED,
GREEN,
BLUE
};
enum color c = BLUE;
printf(“%d”, c);
a) 0
b) 1
c) 2
d) BLUE
50. What is the purpose of the “sizeof” operator in C Language?
a) It returns the size of a variable or data type in bytes.
b) It returns the address of a variable.
c) It returns the ASCII value of a character.
d) It returns the value of a variable.
Answer of the MCQ on C: MCQ on C Language with Answers
- c) real
- b) *
- d) 11
- b) int array[10];
- c) 6
- a) To determine the size of objects
- b) 10
- b) while
- a) #define CONSTANT 10
- a) 5
- a) It terminates the current loop and transfers control to the next iteration.
- d) stdio.h
- b) 5, 6
- a) It terminates the current loop and transfers control to the next iteration.
- c) 32
- c) It is used to specify the block of code to be executed if the condition in the if statement is false.
- a) int *ptr;
- a) 2
- d) ^^
- b) 5
- d) It exits the current function and returns a value.
- d) char str[6] = “Hello”;
- b) 11
- a) It performs logical AND operation between two operands.
- a) True
- b) It performs logical OR operation between two operands.
- a) True
- a) It negates the value of a variable.
- a) True
- d) It is used to specify the block of code to be executed based on the value of an expression.
- b) Two
- d) It exits the current switch statement and transfers control to the statement after the switch.
- a) 0 1 2 3 4
- b) It is used to execute a block of code at least once, and then repeatedly until a condition is satisfied.
- a) 0 1 2 3 4
- d) It is used to execute a block of code based on the value of a variable.
- a) 0 1 2 3 4
- c) It skips the remaining statements in a loop and continues with the next iteration.
- c) 0 1 3 4
- b) It transfers control to a specified label within the current function.
- a) 0 1 2 End
- a) It is used to define a new data type.
- b) 5
- a) It is used to define a new data type.
- b) 20
- d) It is used to access the members of a structure through a pointer.
- b) 20
- c) It is used to define a constant.
- c) 2
- a) It returns the size of a variable or data type in bytes.