C Miscellaneous(C Program ) Questions and Answers
Explanation:-
Answer: Option D. -> None of TheseCorrect Output : mmmm aaaa nnnn
s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].
Explanation:-
Answer: Option B. -> 1 2The sizeof() operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof(p) gives 2.
Explanation:-
Answer: Option B. -> I love ExamvedaFor floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb: Never compare or at-least be cautious when using floating point numbers with relational operators (== , >,
Explanation:-
Answer: Option B. -> 5 4 3 2 1When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.
Explanation:-
Answer: Option B. -> threeThe default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.
Explanation:-
Answer: Option C. -> 2Here unary minus (or negation) operator is used twice. Same maths rule applies, ie. minus * minus= plus.
Note: However you cannot give like --2. Because -- operator can only be applied to variables as a decrement operator (eg., i--). 2 is a constant and not a variable.