C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 15)
15.
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("%c\n", 7["IndiaBIX"]);
return 0;
}
Discussion:
43 comments Page 5 of 5.
Varun said:
1 decade ago
No it will not print all the characters after 6 characters. if we keep 7+"IndiaBIX" then we will get output as you told..@narendra
Prasad said:
1 decade ago
Suppose take an example...
int a[3]={10,20,30};
printf("\n%d%d%d",0[a],1[a],2[a]);
same way as a[0] a[2]....
in the above example 7 is treated as index.
So it takes 7th character
int a[3]={10,20,30};
printf("\n%d%d%d",0[a],1[a],2[a]);
same way as a[0] a[2]....
in the above example 7 is treated as index.
So it takes 7th character
Shabana said:
1 decade ago
Here in the program.
I - 0.
n - 1.
d - 2.
i - 3.
a - 4.
B - 5.
I - 6.
X - 7.
The compiler will skip all 6 character and it will 7th character X only because of 7["IndiaBIX"].
I - 0.
n - 1.
d - 2.
i - 3.
a - 4.
B - 5.
I - 6.
X - 7.
The compiler will skip all 6 character and it will 7th character X only because of 7["IndiaBIX"].
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers