I get an error code after the output: CRL 80004005

//This program calculates the maximum value in a matrix and divides that value by the other members in its column.
1
2
3
#include <iostream>
#include <iomanip>
using namespace std;

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
48
int main()
{
	const int NUM_VAL =5;
	const int NUM_COL =6;
	
	int matrix_members[6][5] ={ {1.267, 0.167, 0.250, 2.670, 1.000},
	                            {3.240, 0.376, 0.375, 3.400, 1.128},
	                            {7.564, 0.668, 0.500, 4.303, 1.270},
	                            {5.041, 1.043, 0.625, 5.313, 1.410},
	                            {4.660, 1.502, 0.750, 7.650, 1.693},
	                            {5.727, 2.044, 0.875, 3.600, 2.257}};
	int norm_values,
		mem_cel,
		mem_sum;
		
	double max_val;

	cout << setprecision(1)
		 << setiosflags(ios::fixed)
		 << setiosflags(ios::showpoint);
	// Obtains and stores the the matrix members and the maximum value for each cell.

	cout << "Print the normalized matrix value " << NUM_VAL
		 << " For each column. " << endl;
	cout << " Seperate the values by one or more spaces. " << endl;

	for (norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		cout << endl << endl;
		cout << "The value for column " << norm_values + 1 << ": ";
		for (mem_cel =0; mem_cel < NUM_VAL; ++mem_cel)
	
        cout << endl;
	}
	// Calculate and display the maximum value for each column.
	for(norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		mem_sum = 0;
		for(mem_cel = 0; mem_cel < NUM_VAL; ++mem_cel)
			mem_sum += matrix_members[norm_values][mem_cel];
		max_val=(double) mem_sum / NUM_VAL;
	    cout << endl << endl;
		cout << "Maximum value for each column: " << setw(3) << norm_values + 1
			<< " Value is: " << setw(5) << max_val;
	}
	cout << endl;
	return 0;
}


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
syntax error
Deleting intermediate and output files for project 'Week3Program', configuration 'Debug|Win32'
Compiling...
Week3Program.cpp
.\Week3Program.cpp(10) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(10) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(10) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(10) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(10) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(11) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(11) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(11) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(11) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(11) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(12) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(12) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(12) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(12) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(12) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(13) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(13) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(13) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(13) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(13) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(14) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(14) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(14) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(14) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(14) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(15) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(15) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(15) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(15) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
.\Week3Program.cpp(15) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
Linking...
Embedding manifest...
Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\Week3Program\Week3Program\Debug\BuildLog.htm"
Week3Program - 0 error(s), 30 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== I hope I applied the tag codes correctly
For one, you're using int type to hold decimal point numbers.

1
2
3
4
5
6
	int matrix_members[6][5] ={ {1.267, 0.167, 0.250, 2.670, 1.000},
	                            {3.240, 0.376, 0.375, 3.400, 1.128},
	                            {7.564, 0.668, 0.500, 4.303, 1.270},
	                            {5.041, 1.043, 0.625, 5.313, 1.410},
	                            {4.660, 1.502, 0.750, 7.650, 1.693},
	                            {5.727, 2.044, 0.875, 3.600, 2.257}};
Thank for your time and response. I changed the int declaration to to double I get this snytax error.
//This program calculates the maximum value in a matrix and divides that value by the other members in its column.
1
2
3
#include <iostream>
#include <iomanip>
using namespace std;

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
int main()
{
	const int NUM_VAL =5;
	const int NUM_COL =6;
	
	double matrix_members [5][6] =             { {1.267, 0.167, 0.250, 2.670, 1.000},
	                                             {3.240, 0.376, 0.375, 3.400, 1.128},
	                                             {7.564, 0.668, 0.500, 4.303, 1.270},
	                                             {5.041, 1.043, 0.625, 5.313, 1.410},
	                                             {4.660, 1.502, 0.750, 7.650, 1.693},
	                                             {5.727, 2.044, 0.875, 3.600, 2.257}};
	double norm_values,
		   mem_cel,
		   mem_sum,
		   max_val;

	cout << setprecision(1)
		 << setiosflags(ios::fixed)
		 << setiosflags(ios::showpoint);
	// Obtains and stores the the matrix members and the maximum value for each cell.

	cout << "Print the normalized matrix value " << NUM_VAL
		 << " For each column. " << endl;
	cout << " Seperate the values by one or more spaces. " << endl;

	for (norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		cout << endl << endl;
		cout << "The value for column " << norm_values + 1 << ": ";
		for (mem_cel =0; mem_cel < NUM_VAL; ++mem_cel)
	
        cout << endl;
	}
	// Calculate and display the maximum value for each column.
	for(norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		mem_sum = 0;
		for(mem_cel = 0; mem_cel < NUM_VAL; ++mem_cel)
			mem_sum += matrix_members[norm_values][mem_cel];
		max_val=(double) mem_sum / NUM_VAL;
	    cout << endl << endl;
		cout << "Maximum value for each column: " << setw(3) << norm_values + 1
			<< " Value is: " << setw(5) << max_val;
	}
	cout << endl;
	return 0;
}




1
2
3
4
5
6
7
Compiling...
Week3Program.cpp
.\Week3Program.cpp(15) : error C2078: too many initializers
.\Week3Program.cpp(43) : error C2108: subscript is not of integral type
Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\Week3Program\Week3Program\Debug\BuildLog.htm"
Week3Program - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



switch the 5 and 6 in your initilization.

the first number in a 2d array are the rows, the second the columns. You have 6 rows and 5 columns.

Also, make norm_values and mem_cel ints.
Last edited on
Thank you for time and response I changed the initilization and made norm_values and mem_cel ints the program has no errors and 1 succeeded but the output has a error CRL 80004005.
1
2
3
4
 //This program calculates the maximum value in  a matrix and divides that value by the other members in its column.
#include <iostream>
#include <iomanip>
using namespace std;

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
48
int main()
{
	const int NUM_ROW =6;
	const int NUM_COL =5;
	
	double matrix_members [6][5] =             { {1.267, 0.167, 0.250, 2.670, 1.000},
	                                             {3.240, 0.376, 0.375, 3.400, 1.128},
	                                             {7.564, 0.668, 0.500, 4.303, 1.270},
	                                             {5.041, 1.043, 0.625, 5.313, 1.410},
	                                             {4.660, 1.502, 0.750, 7.650, 1.693},
	                                             {5.727, 2.044, 0.875, 3.600, 2.257}};
	int norm_values,
		   mem_cel;

	double mem_sum,
		   max_val;

	cout << setprecision(1)
		 << setiosflags(ios::fixed)
		 << setiosflags(ios::showpoint);
	// Obtains and stores the the matrix members and the maximum value for each cell.

	cout << "Print the normalized matrix value " << NUM_ROW
		 << " For each column. " << endl;
	cout << " Seperate the values by one or more spaces. " << endl;

	for (norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		cout << endl << endl;
		cout << "The value for column " << norm_values + 1 << ": ";
		for (mem_cel =0; mem_cel < NUM_ROW; ++mem_cel)
	
        cout << endl;
	}
	// Calculate and display the maximum value for each column.
	for(norm_values =0; norm_values < NUM_COL; ++norm_values)
	{
		mem_sum = 0;
		for(mem_cel = 0; mem_cel < NUM_ROW; ++mem_cel)
			mem_sum += matrix_members[norm_values][mem_cel];
		max_val=(double) mem_sum / NUM_ROW;
	    cout << endl << endl;
		cout << "Maximum value for each column: " << setw(3) << norm_values + 1
			<< " Value is: " << setw(5) << max_val;
	}
	cout << endl;
	return 0;
}


1
2
3
4
5
6
7
8
Deleting intermediate and output files for project 'Week3Program', configuration 'Debug|Win32'
Compiling...
Week3Program.cpp
Linking...
Embedding manifest...
Build log was saved at "file://c:\Users\Martin\Documents\Visual Studio 2008\Projects\Week3Program\Week3Program\Debug\BuildLog.htm"
Week3Program - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========





Where is the error?
thank you for responding i really appreciate your feedback. The error CRL 80004005 occurs in the output after compiling I don't get the intend output for the program just a blank output page with the CRL 80004005 error code. The intended output should read these couts:

1
2
3
cout << "Print the normalized matrix value " << NUM_ROW
		 << " For each column. " << endl;
	cout << " Seperate the values by one or more spaces. " << endl;


cout << "The value for column " << norm_values + 1 << ": ";

1
2
cout << "Maximum value for each column: " << setw(3) << norm_values + 1
			<< " Value is: " << setw(5) << max_val;


the for loops should calculate and compile for these couts I'm stuck and can't find where I coded wrong

[code] thank you oghmaosiris and bluezor for showing me my errors I'm learning from my mistake.



this is the output I get:

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
48
49
50
51
52
53
54
Print the normalized matrix value 6 For each column.
 Seperate the values by one or more spaces.


The value for column 1:







The value for column 2:







The value for column 3:







The value for column 4:







The value for column 5:







Maximum value for each column:   1 Value is:   1.4

Maximum value for each column:   2 Value is:   2.7

Maximum value for each column:   3 Value is:   3.2

Maximum value for each column:   4 Value is:   3.0

Maximum value for each column:   5 Value is:   3.7
Press any key to continue . . .
Thank you so much for your feedback I realize now I have to rewrite most of the program.
Topic archived. No new replies allowed.