C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 20)
20.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str1[] = "India";
    char str2[] = "BIX";
    char *s1 = str1, *s2=str2;
    while(*s1++ = *s2++)
        printf("%s", str1);

    printf("\n");
    return 0;
}
IndiaBIX
BndiaBIdiaBIXia
India
(null)
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
43 comments Page 5 of 5.

Raju said:   1 decade ago
The 1st letter of *s2++ is BIX = 'B'.

'B' is assigned to the 1st letter of S1 so it becomes Bndia.

Rest are follows the same way.

Shrinidhi said:   2 decades ago
Someone please explain.

Aravind said:   2 decades ago
How it comes please explain anyone pa.


Post your comments here:

Your comments will be displayed after verification.