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;
}
Error: in printf
Nothing will print
print "X" of IndiaBIX
print "7"
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
43 comments Page 1 of 5.

Sathiya said:   2 decades ago
How does it takes 7th character("X") from IndiaBIX?

7["IndiaBIX"] shall we define like this?

Shamini said:   2 decades ago

printf("%c\n", 7["IndiaBIX"]);


It is printing the 7th character of the string "IndiaBIX".

I-0,
n-1,
d-2,
i-3,
a-4,
B-5,
I-6,
X-7.

Sathya said:   2 decades ago
Thanks Shamini.

Gopi said:   1 decade ago
Good. Thank you.

Narendra said:   1 decade ago
I think when we write like that then compiler will skip first 6 letters &then print remaining.

UmU said:   1 decade ago
@narender no you are wrong.

@samini good thnx. :).

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.

Wikiok said:   1 decade ago
myarray[5] == 5[myarray]

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


Post your comments here:

Your comments will be displayed after verification.