C Fundamentals Page-4
1. If integer needs two bytes of storage, then maximum value of an unsigned integer is
a) 216 – 1
b) 215 – 1
c) 215
d) 216
Answer: A
Explanation: An unsigned integer containing n bits can have a value between 0 and 2n - 1 (which is 2n different values).
2. What is the correct value to return to the operating system upon the successful completion of a program?
a) 1
b) -1
c) 0
d) 2
Answer: C
Explanation: No explanation is given for this question.
3. Which is the only function all C programs must contain?
a) start()
b) system()
c) main()
d) printf()
Answer: C
Explanation: No explanation is given for this question.
4. Which of the following is not a correct variable type?
a) real
b) float
c) int
d) double
Answer: B
No explanation is given for this question.
5. What number would be shown on the screen after the following statements of C are executed?
char ch;
int i;
ch = 'G;
i = ch - 'A;
printf("%d", i);
a) 6
b) 5
c) 1
d) None of these.
Answer: A
Since the ASCII value of G is 71 and the garbage value if A is 65 and hence the difference is 6.
6. Which of following is not a valid name for a C variable?
a) ALgbly
b) Alg_bly
c) Alg bly
d) both a and b
Answer: C
No spaces are allowed in the variable names.
7. Find the output of the following program.
void main(){
int i = 01289;
printf("%d", i);
}
a) 0289
b) 1289
c) 723
d) Syntax error
Answer: D
The prefix 0 in an integer value indicates octal value. In octal value use of 8 and 9 is not allowed and hence the error.
8. A C variable cannot start with
void main(){
int i = 065, j = 65;
printf("%d %d", i, j);
}
a) 53 65
b) 65 65
c) 053 065
d) Syntax error
Answer: A
As octal 65 ( 065 ) is equivalent of decimal value 53.
9. If ASCII value of 'x' is 120, then what is the value of the H, if H = ('x' – 'w' ) / 3;
a) 1
b) 2
c) 3
d) 0
Answer: D
Because 'x'-'w' = 120-119. And hence 1/3 results in 0(integer division).
10. What is the difference between a declaration and a definition of a variable?
a) Both can occur multiple times, but a declaration must occur first.
b) A definition occurs once, but a declaration may occur many times.
c) A declaration occurs once, but a definition may occur many times.
d) There is no difference between them.
e) Both can occur multiple times, but a definition must occur first.
Answer: C
No explanation is given for this question