+ 1

What is the output of this code? Why?

char str[] = "%d %c", arr[] = "Sololearn"; printf(str, 0[arr], 2[arr + 3]); https://code.sololearn.com/cuQCT8ENQIzb/?ref=app

6th Sep 2019, 12:13 AM
qin
qin - avatar
4 Answers
+ 13
Here 0[arr] means first element of array and it is S . And here %d is given so we have to calculate ASCII value of S and it is 83. 2[arr + 3] = 2[0 + 3] = 2[3] = 6 mean 6th element of array and it is e. So the answer is 83 e.
6th Sep 2019, 1:32 AM
Rohitman
Rohitman - avatar
+ 11
Array start with 0 so arr =0 2[arr +3] =2[0 + 3] =2[3] =6 So, the 6th element of an arr is e. I hope you understand.
6th Sep 2019, 2:57 AM
Rohitman
Rohitman - avatar
+ 1
Rohit Gupta 2[3]=6 i can't understandđŸ˜„đŸ˜„
6th Sep 2019, 2:20 AM
qin
qin - avatar
+ 1
Rohit Gupta thanks i got it
6th Sep 2019, 3:59 AM
qin
qin - avatar