Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

array of alpha of 50 components

Avatar of texanweb
texanweb asked on
7 Comments1 Solution3172 ViewsLast Modified:
Write a C++ program that declares an array of alpha of 50 components of type double. Initialize the array so that the first 25 components are equal to the square of the index variable. Out put the array so that 10 elements per line are printed.  Also, use a for loop to compute and print the sum of the values stored in the array.

The program is working, but its giving me the wrong answer.

#include <iostream>
using namespace std;

int main()
      double alpha[50];
      double BETA[50] = {};
      int i,j,d;

      for (i = 0; i < 25; i++)
            alpha[i] = i * i;

      for (d = 25; d < 50; d++)
            alpha[d] = i * i  * i;

      for (i = 0; i < 5; i++)
            for (j = 0; j < 10; j++)
                  cout << BETA[i*10+j] << " ";
            cout << endl;
    cout << endl;
    cout << "The square of the first 25 numbers is: " << alpha[i] << endl;
    cout << "The triple of the last 25 numbers is: " << alpha[d] << endl;

      return 0;
Avatar of jkr
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers