ExamVeda
Login
Home
This question belongs to C Program C Miscellaneous
C Miscellaneous
?

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]);
}

Answer & Solution
Correct Answer: Option D
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].
Examveda
Question posted by Examveda
Community

Join the Discussion

10 Comments
Shaziya Hasan
Shaziya Hasan 6 years ago
Could anyone please tell me the meaning of s[i] in the for loop condition. I mean what does it depict?
SHAIK MOHASEEN
SHAIK MOHASEEN 7 years ago
what is the name of the printed circuit board
Pankaj Lakade
Pankaj Lakade 9 years ago
the ans is mmmm aaaa nnnn
so option D is the correct..(none of these)
Abhishek Singh
Abhishek Singh 9 years ago
Ans is Wrong.
Shital Kanade
Shital Kanade 9 years ago
But answer will be mmmm aaaa nnnn
SUKHBINDER SINGH
SUKHBINDER SINGH 9 years ago
"mmmm aaaa nnnn "
Ankush Sah
Ankush Sah 10 years ago
it output is "mmmm aaaa nnnn "
Sonam Gaikwad
Sonam Gaikwad 10 years ago
answer is mmmm aaaa nnnn
Vkp Kumar
Vkp Kumar 10 years ago
answer should be mmmm aaaa nnnn
Jay Karan
Jay Karan 10 years ago
answer must be mmmm aaaa nnnn