Shows zero values

Hi guys: Can any one please tell me what i made mistake as it shows the output zero. Thanks.

#include <iostream>
#include <iomanip>
using namespace test;

int main()
      double scores[5][3] = {{75.5, 80.5, 0.0},
                                       {88.5, 89.5, 0.0},
                                        {63.0, 54.0, 0.0},
                                       {100.0, 99.0, 0.0},
                                       {88.5, 88.5, 0.0}};
      for (int row = 0; row < 5; row += 1)
            scores[row][0] = scores[row][0] + scores[row][1] / 2;

      cout << endl << fixed << setprecision(1);
      for (int row = 0; row < 5; row += 1)
            cout << "The " << row + 1 << " average: " 
                  << scores[row][2] << endl;

    return 0;
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Your print statement is always printing the 3rd element (index 2) in each set, which you defaulted to 0.0 in each case. Is this what you intended?
mustish1Author Commented:
How to change this line
käµfm³d 👽Commented:
How to change this line
That depends on what it is you are trying to print. My guess is that you want to print the values you just added and stored. If so, you stored them in the first slot (index 0); change your print statement to point there:
cout << "The " << row + 1 << " average: "
                  << scores[row][0] << endl;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Did you mean to print   scores[row][0] ?
Did you mean to set  scores[row][2] to something other than 0?
mustish1Author Commented:
scores[row][2] = (scores[row][0] + scores[row][1]) / 2.0;
käµfm³d 👽Commented:
NP. Glad to help  : )
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.