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 4 of 5.
Sanketrjain said:
1 decade ago
Thanks raghu and shamini.
Raghu said:
1 decade ago
It is just trick of mathematics. a[3] = 3[a] --> they are commutative both are expanded by compiler as *(a+3) and *(3+a) respectively. Even you can assign a variable to 3[a] = "X" which is same as a[3]="X".
Venky said:
1 decade ago
Actually: num[i]<=>*(num+i)<=>*(i+num)<=>i[num]
So 7 is index and indiabix is string. Thus X of indiabix.
So 7 is index and indiabix is string. Thus X of indiabix.
Rajutaya@gmail.com said:
1 decade ago
Ya correct guys, if it is printf("%d",7[indiabiA]);
means it will print the integer values as A=65
means it will print the integer values as A=65
Arvind said:
1 decade ago
Thnx wikiok.
Wikiok said:
1 decade ago
myarray[5] == 5[myarray]
Manoj said:
1 decade ago
Hey program is good, because whenever complier can't define any data type or user define %c means char or you can modify this program or define %f,
%d then you will get satisfied answer.
%d then you will get satisfied answer.
UmU said:
1 decade ago
@narender no you are wrong.
@samini good thnx. :).
@samini good thnx. :).
Narendra said:
1 decade ago
I think when we write like that then compiler will skip first 6 letters &then print remaining.
Gopi said:
1 decade ago
Good. Thank you.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers