void main()
{
int a=1;
printf(“%d%d%d”,a++,++a,a);
}
ur predicted output 1 3 3 is wrong,then…..
OUTPUT:
2 2 1
this is because control in printf statement travels from right to left and not from left to right
hence first ‘a’ is computed then ‘++a’ and then ‘a++’ and printed in the order u have specified
got it..
void main()
{
char ch[10];
printf(“enter:”);
gets(ch);
printf(“\n%c”,(*ch+1));
}
output:
enter:APPLE
B
can’t understand just go through the explanation….
if u enter “APPLE” in to the array ch then (*ch+1) will first add the number
one with the first character of the array (actually the ascii value of the character) hence here
when one is added with the ascii value of ‘A’ produces the next character ‘B’ which is the output.
void main()
{
char ch[10];
printf(“enter:”);
gets(ch);
printf(“\n%c”,(*ch+1));
}
output:
enter:APPLE
B
can’t understand just go through the explanation….
if u enter “APPLE” in to the array ch then (*ch+1) will first add the number
one with the first character of the array (actually the ascii value of the character) hence here
when one is added with the ascii value of ‘A’ produces the next character ‘B’ which is the output.
feedback