In the context of the following printf() in C, pick the best statement.
i) printf("%d",8); ii) printf("%d",090); iii) printf("%d",00200); iv) printf("%d",0007000); |
(A) Only i) would compile. And it will print 8.
(B) Both i) and ii) would compile. i) will print 8 while ii) will print 90
(C) All i), ii), iii) and iv) would compile successfully and they will print 8, 90, 200 & 7000 respectively.
(D) Only i), iii) and iv) would compile successfully. They will print 8, 128 and 3584 respectively.
Answer: (D)
Explanation:
As per C standard, “An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 through 7 only.”
So 090 isn’t valid because 0 prefix is used for octal but 9 isn’t valid octal-digit.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- C Quiz - 109 | Question 3
- C Quiz - 106 | Question 1
- C Quiz - 108 | Question 5
- C Quiz - 106 | Question 2
- C Quiz - 106 | Question 3
- C Quiz - 106 | Question 4
- C Quiz - 106 | Question 5
- C Quiz - 107 | Question 1
- C Quiz - 107 | Question 2
- C Quiz - 112 | Question 1
- C Quiz - 108 | Question 2
- C Quiz - 108 | Question 4
- C Quiz - 108 | Question 1
- C Quiz - 107 | Question 5
- C Quiz - 107 | Question 4
- C Quiz - 108 | Question 3
- C Quiz - 109 | Question 1
- C Quiz - 107 | Question 3
- C Quiz - 111 | Question 4
- C Quiz - 109 | Question 2

