Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

nphuongsun93 Group Title

This one appears in my exam, i was partly wrong and I don't know why. Please check. C++ language. Consider the following declarations: const int SIZE = 12; int list[SIZE]; int *listPtr = list; int j = 0; int sum = 0; Which of the following correctly finds the sum of all the elements of list? i) for (j = SIZE - 1; j >= 0; --j) sum += list[j]; ii) sum = listPtr[0]; for (j = 1; j < SIZE; j ++) sum += listPtr[j]; iii) for (listPtr = list; listPtr != list + Size; sum += *(listPtr++)); I chose i and ii, which is partly wrong (got 3/5 points). thank you in advance.

  • one year ago
  • one year ago

  • This Question is Closed
  1. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Assuming that `Size` in the third option should be `SIZE`, all three methods seem correct to me (also tested it with a small C program and all three methods give the same result).

    • one year ago
  2. nphuongsun93 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you, sry couldn't reply to you sooner. my openstudy just doesn't load lately.

    • one year ago
    • Attachments:

See more questions >>>

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.