Examveda
Examveda

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

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].

This Question Belongs to C Program >> C Miscellaneous

Join The Discussion

Comments ( 10 )

  1. Shaziya Hasan
    Shaziya Hasan :
    4 years ago

    Could anyone please tell me the meaning of s[i] in the for loop condition. I mean what does it depict?

  2. SHAIK MOHASEEN
    SHAIK MOHASEEN :
    5 years ago

    what is the name of the printed circuit board

  3. Pankaj Lakade
    Pankaj Lakade :
    6 years ago

    the ans is mmmm aaaa nnnn
    so option D is the correct..(none of these)

  4. Abhishek Singh
    Abhishek Singh :
    7 years ago

    Ans is Wrong.

  5. Shital Kanade
    Shital Kanade :
    7 years ago

    But answer will be mmmm aaaa nnnn

  6. SUKHBINDER SINGH
    SUKHBINDER SINGH :
    7 years ago

    "mmmm aaaa nnnn "

  7. Ankush Sah
    Ankush Sah :
    7 years ago

    it output is "mmmm aaaa nnnn "

  8. Sonam Gaikwad
    Sonam Gaikwad :
    7 years ago

    answer is mmmm aaaa nnnn

  9. Vkp Kumar
    Vkp Kumar :
    7 years ago

    answer should be mmmm aaaa nnnn

  10. Jay Karan
    Jay Karan :
    8 years ago

    answer must be mmmm aaaa nnnn

Related Questions on C Miscellaneous