A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
a[]={0,1,2,3,4,5,6,7,8,9,10};
i=0;
a[i]=a[++i+a[++i]]+a[++i];
cout<<a[i];
ans 9 whats the logic?
 2 years ago
a[]={0,1,2,3,4,5,6,7,8,9,10}; i=0; a[i]=a[++i+a[++i]]+a[++i]; cout<<a[i]; ans 9 whats the logic?

This Question is Closed

Matrix65
 2 years ago
Best ResponseYou've already chosen the best response.0cout<<a[9]; //if u output 9

03225186213
 2 years ago
Best ResponseYou've already chosen the best response.0i know ans is 9 how it came(evaluated)?

jon.stromer.galley
 2 years ago
Best ResponseYou've already chosen the best response.1This is a test of your understanding of order of operations. At std::cout you should see that i == 3. What is a[ 3 + a[3]] + a[3]?

03225186213
 2 years ago
Best ResponseYou've already chosen the best response.0i evaluated like a[1+a[2]]+a[3]; tell me the logic of 3 at all places

jon.stromer.galley
 2 years ago
Best ResponseYou've already chosen the best response.1++i is evaluated first, so the function is: a[ 3 + a[3]] + a[3] not a[1+a[2]]+a[3] thus a[ 3 + a[3]] + a[3] == a[3 +3] + 3 == a[6] + 3 == 6 + 3 == 9
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.