C Language Mutiple Choice Questions
C Language Mutiple Choice Questions
Solution: (c) Only alphanumeric characters and few special characters like ‘_’ are allowed
in variable name is C. The special character @ is not allowed.
2. A function
5. If integer needs two bytes of storage, then the minimum value of a signed integer in
C would be
a) −(216 − 1)
b) 0
𝑐𝑐) − (215 − 1)
𝑑𝑑) − 215
Solution: (d) The first bit is used to indicate whether it is signed or unsigned integer.
ASSIGNMENT 2 SOLUTION
6. Which of the following statement is correct?
I Keywords are those words whose meaning is already defined by Compiler.
II Keywords cannot be used as variable name.
III There are 32 keywords in C
IV C keywords are also called as reserved words.
a) I and II
b) II and III
c) I, II and IV
d) All of the above
Solution: (d) All of the above are correct.
#include <stdio.h>
int main()
{
float a = 6.0;
printf ("%.2f", (9/5)*a + 11);
return 0;
}
a) 21.00
ASSIGNMENT 2 SOLUTION
b) 19.00
c) 0.00
d) 17.00
Since 9 and 5 are integers, integer arithmetic happens in subexpression (9/5) and we get 1
as its value. To fix the above program, we can use 9.0 instead of 9 or 5.0 instead of 5 so that
floating point arithmetic happens.
9. The following C program converts the temperature from Celsius (C) to Fahrenheit
(F). Fill the blanks with the proper formula to do it.
#include <stdio.h>
int main()
{
float C = 37.5, F;
F = _____________;
printf("%.2f", F);
return 0;
}
a) 1.8*C +32
b) 1.8*(C + 32)
c) 1.8*C - 32
d) C/1.8 + 32
𝐶𝐶 𝐹𝐹−32
Solution: (a) 1.8*C +32. The formula is = , that is simplified to the given option (a).
5 9
10.The following C program swaps the value of two numbers without using any third
variable. What will be the correct option to fill up the blank?
#include <stdio.h>
int main()
{
int a=2, b=3;
printf("The values before swapping a = %d, b=%d",a,b);
____________________________________