R4RIN
MCQS
C/C MCQ Quiz Hub
C Programming - MCQ Questions Set 2
Choose a topic to test your knowledge and improve your C/C skills
1. What will be the value of the following assignment expression? (x = foo())!= 1 considering foo() returns 2
2
True
1
0
2. Operation “a = a * b + a” can also be written as ___________
a *= b + 1;
(c = a * b)!=(a = c + a);
a = (b + 1)* a;
All of the mentioned
3. What will be the final value of c in the following C statement? (Initial value: c = 2) c <<= 1;
c = 1;
c = 2;
c = 3;
c = 4;
4. Which of the following is an invalid assignment operator?
a %= 10;
a /= 10;
a |= 10;
None of the mentioned
5. In expression i = g() + f(), first function called depends on _________
Compiler
Associativiy of () operator
Precedence of () and + operator
Left to write of the expression
6. In expression i = g() + f(), first function called depends on ______
Compiler
Associativiy of () operator
Precedence of () and + operator
Left to write of the expression
7. Which of the following operators has an associativity from Right to Left?
&lt;=
&lt;&lt;
==
+=
8. Which operators of the following have same precedence? P. "!=", Q. "+=", R. "<<="
P and Q
Q and R
P and R
P, Q and R
9. Comment on the following statement. n = 1;printf("%d, %dn", 3*n, n++);
Output will be 3, 2
Output will be 3, 1
Output will be 6, 1
Output is compiler dependent
10. Which of the following option is the correct representation of the following C statement? e = a * b + c / d * f;
e = (a * (b +(c /(d * f))));
e = ((a * b) + (c / (d * f)));
e = ((a * b) + ((c / d)* f));
Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f));
11. Which of the following is the correct order of evaluation for the given expression? a = w % x / y * z;
% / * =
/ * % =
= % * /
* % / =
12. Which function in the following expression will be called first? a = func3(6) - func2(4, 5) / func1(1, 2, 3);
func1();
func2();
func3();
Cannot be predicted
13. Which of the following operator has the highest precedence in the following?
()
sizeof
*
+
14. Which of the following is a ternary operator?
&amp;&amp;
&gt;&gt;=
?:
-&gt;
15. Which of the following are unary operators?
sizeof
–
++
all of the mentioned
16. Where in C the order of precedence of operators do not exist?
Within conditional statements, if, else
Within while, do-while
Within a macro definition
None of the mentioned
17. Associativity of an operator is _______
Right to Left
Left to Right
Random fashion
Both Right to Left and Left to Right
18. Which of the following method is accepted for assignment?
5 = a = b = c = d;
a = b = c = d = 5;
a = b = 5 = c = d;
None of the mentioned
19. Which of the following is NOT possible with any 2 operators in C?
Different precedence, same associativity
Different precedence, different associativity
Same precedence, different associativity
All of the mentioned
20. Which of the following is possible with any 2 operators in C?
Same associativity, different precedence
Same associativity, same precedence
Different associativity, different precedence
All of the mentioned
21. Which of the following is an invalid if-else statement?
if (if (a == 1)){}
if (func1 (a)){}
if (a){}
if ((char) a){}
22. The C code ‘for(;;)’ represents an infinite loop. It can be terminated by ______
break
exit(0)
abort()
terminate
23. Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
for (i = n; i&gt;0; i–)
for (i = n; i &gt;= 0; i–)
for (i = n-1; i&gt;0; i–)
for (i = n-1; i&gt;-1; i–)
24. Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3)?
variable
function
typedef
macros
25. Which keyword can be used for coming out of recursion?
break
return
exit
both break and return
26. The keyword ‘break’ cannot be simply used within ______
do-while
if-else
for
while
27. Which keyword is used to come out of a loop only for that iteration?
break
continue
return
none of the mentioned
28. Which of the following is a correct format for declaration of function?
return-type function-name(argument type);
return-type function-name(argument type){}
return-type (argument type)function-name;
all of the mentioned
29. Which of the following function declaration is illegal?
int 1bhk(int);
int 1bhk(int a);
int 2bhk(int*, int []);
all of the mentioned
30. Can we use a function as a parameter of another function? [Eg: void wow(int func())].
Yes, and we can use the function value conveniently
Yes, but we call the function again to get the value, not as convenient as in using variable
No, C does not support it
This case is compiler dependent
31. The value obtained in the function is given back to main by using ________ keyword.
return
static
new
volatile
32. What is the return-type of the function sqrt()?
int
float
double
depends on the data type of the parameter
33. What is the default return type if it is not specified in function definition?
void
int
double
short int
34. Functions can return structure in C?
TRUE
FALSE
Depends on the compiler
Depends on the standard
35. Functions can return enumeration constants in C?
TRUE
false
depends on the compiler
depends on the standard
36. Functions in C are always _____
Internal
External
Both Internal and External
External and Internal are not valid terms for functions
37. Global variables are _______
Internal
External
Both Internal and External
None of the mentioned
38. Array sizes are optional during array declaration by using ______ keyword.
auto
static
extern
register
39. Which of following is not accepted in C?
static a = 10; //static as
static int func (int); //parameter as static
static static int a; //a static variable prefixed with static
all of the mentioned
40. Which of the following cannot be static in C?
Variables
Functions
Structures
None of the mentioned
41. When compiler accepts the request to use the variable as a register?
It is stored in CPU
It is stored in cache memory
It is stored in main memory
It is stored in secondary memory
42. Which data type can be stored in register?
int
long
float
all of the mentioned
43. Which of the following operation is not possible in a register variable?
Reading the value into a register variable
Copy the value from a memory variable
Global declaration of register variable
All of the mentioned
44. Which among the following is the correct syntax to declare a static variable register?
static register a;
register static a;
Both static register a; and register static a;
We cannot use static and register together
45. Register variables reside in ________
stack
registers
heap
main memory
46. Automatic variables are _________
Declared within the scope of a block, usually a function
Declared outside all functions
Declared with the auto keyword
Declared within the keyword extern
47. What is the scope of an automatic variable?
Exist only within that scope in which it is declared
Cease to exist after the block is exited
Exist only within that scope in which it is declared &amp; exist after the block is exited
All of the mentioned
48. Automatic variables are allocated memory in ____
heap
Data segment
Code segment
stack
49. Automatic variables are initialized to __
Zero
Junk value
Nothing
Both Zero &amp; Junk value
50. Which of the following storage class supports char data type?
register
static
auto
all of the mentioned
Submit