Determine Output:
void main()
{
char s[]="man";
int i;
for(i=0; s[i]; i++)
printf("%c%c%c%c ", s[i], *(s+i), *(i+s), i[s]);
}
void main()
{
char s[]="man";
int i;
for(i=0; s[i]; i++)
printf("%c%c%c%c ", s[i], *(s+i), *(i+s), i[s]);
}
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
Answer: Option D
Solution(By Examveda Team)
Correct 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].Join The Discussion
Comments ( 10 )
Related Questions on C Miscellaneous
Determine output:
void main()
{
int const *p=5;
printf("%d", ++(*p));
}
A. 6
B. 5
C. Garbage Value
D. Compiler Error
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Determine Output:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
A. 5 5 5 5 5
B. 5 4 3 2 1
C. Infinite Loop
D. None of These
Could anyone please tell me the meaning of s[i] in the for loop condition. I mean what does it depict?
what is the name of the printed circuit board
the ans is mmmm aaaa nnnn
so option D is the correct..(none of these)
Ans is Wrong.
But answer will be mmmm aaaa nnnn
"mmmm aaaa nnnn "
it output is "mmmm aaaa nnnn "
answer is mmmm aaaa nnnn
answer should be mmmm aaaa nnnn
answer must be mmmm aaaa nnnn