Multiplying elements in array

I need help with the formula to calculate my array
#include <iostream>
#include <iomanip>
using namespace std;


int main()
{
const int SIZE_ARRAY = 5;
double myArray[ SIZE_ARRAY ];
double total = 0.0;

// initialize elements of array to 0
for ( int i = 0; i < SIZE_ARRAY; i++ )
{
cout<<"\n\t Array initialized to 0.0.\n\n" << endl;
cout << "\t Let's fill in the array with decimals!" << endl;


cout << "Enter array element";
cout << i << ": ";
cin >> myArray [i];
}
// output contents of array in tabular format
cout << "\n\nSubscript" << setw( 13 ) << "Element" << endl;
for ( int i =0; i < SIZE_ARRAY; i++ )
cout << setw( 5 ) << i << setw( 14 ) << myArray[ i ] << endl;

// assign each elements of array to myArray [i]
for ( int i = 0; i < SIZE_ARRAY; i++ )
{
myArray[i] = i;

//total elements of the array
cout << fixed << setprecision(4);

total =

// ??????????????????????????????????? I am confused on the formula to get my product to calculate properly

* myArray[i];

}

cout << "\n\n\tTotal product of array elements is: " << total <<endl;
cout << "\n\n";

system("PAUSE");
return 0;

} // end main
// Initializing an array, filling an array and manipulating elements.
//Programmer: Carlos Matos
#include <iostream>
#include <iomanip>
using namespace std;


int main()
{
const int SIZE_ARRAY = 5;
double myArray[ SIZE_ARRAY ];
double total = 1;

// initialize elements of array to 0
for ( int i = 0; i < SIZE_ARRAY; i++ )
{
cout<<"\n\t Array initialized to 0.0.\n\n" << endl;
cout << "\t Let's fill in the array with decimals!" << endl;


cout << "Enter array element";
cout << i << ": ";
cin >> myArray [i];
}
// output contents of array in tabular format
cout << "\n\nSubscript" << setw( 13 ) << "Element" << endl;
for ( int i =0; i < SIZE_ARRAY; i++ )
cout << setw( 5 ) << i << setw( 14 ) << myArray[ i ] << endl;

// assign each elements of array to myArray [i]
for ( int i = 0; i < SIZE_ARRAY; i++ )
{


//total elements of the array
cout << fixed << setprecision(4);
total = total * myArray[i];

}

cout << "\n\n\tTotal product of array elements is: " << total <<endl;
cout << "\n\n";

system("PAUSE");
return 0;

} // end main
Topic archived. No new replies allowed.