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 3 of 5.
Nagesh said:
9 years ago
Can anyone tell me if 7 is not mentioned in the code. Then what will be the output?
Thanks in advance.
Thanks in advance.
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
Narendra said:
1 decade ago
I think when we write like that then compiler will skip first 6 letters &then print remaining.
Mounisha said:
7 years ago
["IndiabiX"].
0-I
1-n
2-d
3-i
4-a
5-b
6-i
7-X
7["IndiabiX"]= it prints X.
0-I
1-n
2-d
3-i
4-a
5-b
6-i
7-X
7["IndiabiX"]= it prints X.
(7)
Manali said:
1 decade ago
char a[]="indiaBIX"
printf("%c \n",7[a]);
You will get same output.
printf("%c \n",7[a]);
You will get same output.
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.
Pankajraj said:
10 years ago
@Wikiok.
Nice ans/example.
Compiler will check condition and print given character.
Nice ans/example.
Compiler will check condition and print given character.
Rhi said:
8 years ago
Well in C, a[i] always gets translated to *(a + i)
So *(a + i) = *(i+ a)
a[i] = i[a].
So *(a + i) = *(i+ a)
a[i] = i[a].
Rajesh said:
9 years ago
Is it work for multi-dimensional array and what is syntax?
Please explain me.
Please explain me.
Mohammed masood said:
1 decade ago
If 0["indiabix"] then I.
If 1["indiabix"] then n and similarly others.
If 1["indiabix"] then n and similarly others.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers