- 2

main() {intarr[]={1,2,3,4,5}; int *ptr, i; ptr=arr+4; for(i=0;i<5;i++) printf(“\n%d”,*(ptr-1)); }

I am getting 20 as a answer, is it correct? Is the output correct? If not then how to solve?

8th Jun 2020, 10:38 AM
Ishita Gupta
Ishita Gupta - avatar
2 Answers
+ 2
You can use code module on SoloLearn to test your codes. This module is for asking your problems related to programming and related stuffs. Thank you
8th Jun 2020, 11:01 AM
Hardik Sharma
Hardik Sharma - avatar
+ 1
How? Not correct.. .. Edit: I think you are not mentioned your doubt clearly.. If any mention it.. Edit:? ptr=arr+4 ; by this ptr points to last value 5. Next your output *(ptr-1) always points to 4. So 4 printed in 5 times..
8th Jun 2020, 11:09 AM
Jayakrishna 🇼🇳