330 views
1 votes
1 votes

what is the output?

1 Answer

Best answer
2 votes
2 votes
In this, *++ptr will increment the pointer first and then assign the value pointed by the pointer to the variable. *ptr++ will first assign the value pointed by the pointer to the variable.

So,

a=*++ptr; will cause the pointer point to 'a' in "MadeEasy" first and then assign the value 'a' to variable a

b=*ptr++ will cause first assign value 'a' to the variable b and then shift the pointer to d

similarly, in second iteration,

a=*++ptr; will cause a to store e (as pointer is shifted first)

b=*ptr++  will cause b to store e (e is assigned and pointer now points to E)

and in last iteration, a and b both will contain the character 'a'.

Hence a a will be printed
selected by

Related questions

0 votes
0 votes
1 answer
1
himgta asked Sep 12, 2018
381 views
0 votes
0 votes
1 answer
2
himgta asked Sep 6, 2018
437 views
what is the output?
1 votes
1 votes
0 answers
3
Subbu. asked Jul 15, 2022
400 views
Hey How is Gateoverflow test series .. better than other institutes, that means little harder than gate and quality of questions??. #Genuine answers please…