C MCQs (61-90)
61. Which of the following statements about a structure in C is true?
a) A structure can only store one type of data.
b) Structures do not support initialization.
c) A structure can store multiple types of data.
d) Structure members must always be integers.
Answer: c) A structure can store multiple types of data.
62. In C, which of the following is the correct syntax to declare a pointer to a float
?
a) float *ptr;
b) ptr *float;
c) ptr float;
d) ptr float;
Answer: a) float *ptr;
63. What will be the output of the following C program?
#include <stdio.h>
int main() {
int a = 10, b = 5;
printf("%d", a / b);
return 0;
}
a) 2
b) 5
c) 10
d) 50
Answer: a) 2
64. Which of the following is a valid function signature in C?
a) int function(int a);
b) function int(int a);
c) int function(a int);
d) function int(a);
Answer: a) int function(int a);
65. In C, which of the following is used to dynamically allocate memory for an array?
a) malloc()
b) calloc()
c) realloc()
d) All of the above
Answer: d) All of the above
66. Which of the following is a valid C keyword?
a) array
b) function
c) switch
d) var
Answer: c) switch
67. In C, which of the following operators is used to calculate the remainder of division?
a) /
b) %
c) *
d) +
Answer: b) %
68. What is the output of the following code?
#include <stdio.h>
int main() {
int x = 3;
int y = 2;
printf("%d", x * y + 1);
return 0;
}
a) 7
b) 6
c) 8
d) 5
Answer: a) 7
69. What does the sizeof()
operator in C do?
a) Returns the size of a variable in bits.
b) Returns the size of a variable in bytes.
c) Returns the number of elements in an array.
d) None of the above.
Answer: b) Returns the size of a variable in bytes.
70. Which of the following C operators is used to increment the value of a variable by 1?
a) ++
b) +
c) +=
d) —
Answer: a) ++
71. Which of the following C functions is used to compare two strings?
a) compare()
b) cmp()
c) strcmp()
d) strcomp()
Answer: c) strcmp()
72. What is the output of the following code?
#include <stdio.h>
int main() {
int a = 10;
printf("%d", --a);
return 0;
}
a) 9
b) 10
c) 11
d) Error
Answer: a) 9
73. Which of the following is a valid function declaration in C?
a) void func(int x, float y);
b) func(void int x);
c) void func(x, int y);
d) int func(int x, y);
Answer: a) void func(int x, float y);
74. What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x < y) {
printf("True");
} else {
printf("False");
}
return 0;
}
a) True
b) False
c) Error
d) Undefined
Answer: a) True
75. Which of the following is used to access a member of a structure through a pointer in C?
a) .
b) ->
c) *
d) &
Answer: b) ->
76. What is the correct way to initialize a constant in C?
a) const int a = 5;
b) int const a = 5;
c) Both a and b
d) Neither a nor b
Answer: c) Both a and b
77. Which of the following is a valid way to declare a structure in C?
a) struct student { int age; char name[20]; };
b) struct student { int age, char name[20]; };
c) student struct { int age; char name[20]; };
d) struct student(int age, char name[20]);
Answer: a) struct student { int age; char name[20]; };
78. What is the default value of a static
variable in C?
a) 0
b) NULL
c) Undefined
d) Random value
Answer: a) 0
79. What will be the output of the following C program?
#include <stdio.h>
int main() {
int i = 0;
for(i = 0; i < 3; i++) {
if (i == 1) {
continue;
}
printf("%d ", i);
}
return 0;
}
a) 0 1 2
b) 0 2
c) 1 2
d) 2 0
Answer: b) 0 2
80. In C, which of the following is used to declare an array of 5 integers?
a) int arr[5];
b) int[5] arr;
c) arr[5] int;
d) int arr = {5};
Answer: a) int arr[5];
81. In C, how do you declare a pointer to a function that returns an integer and accepts an integer argument?
a) int (*ptr)(int);
b) ptr int(int);
c) int ptr(int);
d) int ptr()(int);
Answer: a) int (*ptr)(int);
82. Which of the following is the correct syntax to define an inline function in C?
a) inline void func() { }
b) void func() inline { }
c) inline function() { }
d) function inline void() { }
Answer: a) inline void func() { }
83. Which of the following C functions is used to free dynamically allocated memory?
a) delete()
b) free()
c) clear()
d) release()
Answer: b) free()
84. What is the purpose of the continue
statement in C?
a) It ends the loop and continues with the next statement outside the loop.
b) It ends the current loop iteration and proceeds with the next iteration of the loop.
c) It causes an infinite loop.
d) It skips the entire loop.
Answer: b) It ends the current loop iteration and proceeds with the next iteration of the loop.
85. What is the result of the expression sizeof(int)
in C?
a) 1
b) 2
c) 4
d) 8
Answer: c) 4
86. Which of the following functions is used to read a single character from standard input in C?
a) scanf()
b) getchar()
c) gets()
d) read()
Answer: b) getchar()
87. What is the correct syntax to declare a union in C?
a) union { int x; float y; };
b) union data { int x, float y; };
c) data union { int x, float y; };
d) union data { int x, y; };
Answer: a) union { int x; float y; };
88. Which of the following is used to end the main function in C?
a) return 0;
b) stop;
c) exit();
d) quit();
Answer: a) return 0;
89. Which of the following is the correct declaration for a function that returns a pointer to an integer?
a) int* func();
b) int func*();
c) int func();
d) int func(void);
Answer: a) int* func();
90. What is the output of the following C program?
#include <stdio.h>
int main() {
int a = 3, b = 4;
printf("%d", a && b);
return 0;
}
a) 1
b) 0
c) 3
d) 4
Answer: a) 1