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.
Arvind said:
1 decade ago
Thnx wikiok.
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
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.
Sathiya said:
2 decades ago
How does it takes 7th character("X") from IndiaBIX?
7["IndiaBIX"] shall we define like this?
7["IndiaBIX"] shall we define like this?
Sanketrjain said:
1 decade ago
Thanks raghu and shamini.
Lavanya said:
1 decade ago
Thanks venky, raghu and shamini.
Sindhu said:
1 decade ago
Thanks wikiok.
Mesv said:
1 decade ago
No need to think more.
7["givenstring"] means it take 7th char of that string.
And string starts from 0 index.
Here "r".
7["givenstring"] means it take 7th char of that string.
And string starts from 0 index.
Here "r".
Devanshmody said:
1 decade ago
They have used %c so it will take one character and 7 is given and x is at 7 position.
HARSHA said:
1 decade ago
It will print all characters after x in the string since there is only one character left it prints x
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers