[Error] Id return 1 exit status

[code]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Initializing an array, filling an array and manipulating elements.
//Programmer: dominologi 
#include <iostream>
#include <cmath>
using namespace std;

#include <iomanip>

int main()
{
   const int SIZE_ARRAY = 4; 
   double myArray [SIZE_ARRAY];  
   double product = 0.0; 


// initialize elements of array to 0
   cout<<"\n\t Let's fill the array with decimal values!\n\n";
   for (int r = 0; r < SIZE_ARRAY; r++)   
// output contents of array  in tabular format
  {
   cout << "Enter array elements "<<r<< ": ";
   cin>> myArray[r];
  }
// end first for statement
  {
  	cout<<"\n\t The array is now filled as follows...\n\n";
  }

  
// output contents of array  in tabular format
   cout << "\n\nSubscript" << setw( 13 ) << "Element" << endl;
   			for ( int o =0; o < 4; o++ )        
      			cout << setw( 5 ) << o << setw( 14 ) << myArray[ o ] << endl;
      
	for ( int b  = 0; b < 4; b++ )  
   {
	   product = product * myArray [b];
   }  
     

   cout << "\n\n\tThe product of the array elements is: " << product <<endl;
   cout << "\n\n";

   system("PAUSE");
   return 0;  
   
} // end main 
[/code]
Last edited on
What is your question or problem?
It ran fine for me.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Last edited on
Thanks for the response. It ran fine after I closed it and opened it again. I apologize but, I have no clue as to what you mean by the <>formatting button. Please explain so that I can comply. Thanks in advance...
The initial value of pruduct is 0. As you know from math 0 * anyNumber = 0;
so The product of arrayElement will be 0.
change initial value of product to 1
I have no clue as to what you mean by the <>formatting button.

Read the link I provided about using code tags.

To the right of the text entry box are 12 buttons under the label "Format:".
Highlight your code and press the <> button (upper left).
[code]
and
[/code]
tags will be applied to the highlighted code.

You can also enter the
[code]
and
[/code]
tags manually.

Topic archived. No new replies allowed.