Imp C Q On Unit I - II
Imp C Q On Unit I - II
1. #include <stdio.h>
2. int main()
3. {
4. signed char chr;
5. chr = 128;
6. printf("%d\n", chr);
7. return 0;
8. }
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned
Answer: b
Explanation: The range of signed character is from -128 to +127. Since we are assigning a value
of 128 to the variable ‘chr’, the result will be negative. 128 in binary is represented as “1000
0000” for character datatype. As you can see that the sign bit is set to 1, followed by 7 zeros (0),
its final decimal value will be -128 (negative 128).
Output: -128
12. What is the precedence of arithmetic operators (from highest to lowest)?
a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /
Answer: a
Explanation: None.
Answer: c
Explanation: None.
14. Which among the following are the fundamental arithmetic operators, i.e, performing the
desired operation can be done using that operator only?
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %
Answer: a
Explanation: None.
15. What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int a = 10;
5. double b = 5.6;
6. int c;
7. c = a + b;
8. printf("%d", c);
9. }
a) 15
b) 16
c) 15.6
d) 10
Answer: a
Explanation: None.