C Programming MCQ - Variables & Datatypes
21. Which of the following can have different meaning in different contexts?
Explanation: & have different meaning in different contexts.
22. Which of the following is not a valid declaration in C?
1. short int x;Â Â Â Â
2. signed short x;
3. short x;
4. unsigned short x;
Explanation: All are valid. First 3 mean the same thing. 4th means unsigned.
23. The minimum number of temporary variable needed to swap the content two variables is?
Explanation: Without any temporary variable ,one can swap two variables easily. For Example :- var a ,b; a=a+b; b=a-b; a=a-b;
24. What is short int in C programming?
Explanation: short is the qualifier and int is the basic datatype.
25. The precedence of arithmetic operators is (from highest to lowest)?
Explanation: All arithmetic operators in C language follow the left to right associativity. Their precedence from highest to lowest is as given below: () => Brackets % => Modulus * => Multiplication / => Division + => Addition - => Subtraction In an arithmetic operation, the higher precedence operators are evaluated first followed by the lower value operators.
26. Which of the following data type will throw an error on modulus operation(%)?
Explanation: Float data type will throw an error on modulus operation(%).
27. Relational operators cannot be used on:
Explanation: structure cannot be used on Relational operators.
28. What is the output of this program?
Explanation: C compiler by default will assign any undeclared float data type as double. Thus 8 4 1 is outputted
29. What is the output of this program?
a = 6u + -16 + 16u + -6;
b = a + 1;
if(a == b)
printf("%u %u",a, b);
Explanation: Clearly, a != b and it execute the else part, where we ask compiler to display the value of a and b.
30. By default a real number is treated as a
Explanation: A double is a more accurate way of representing floating point numbers due to more digits of precision and defaulting to a double for constants will yield more accurate and consistent answers.
Also check :