My program keeps telling me on line 33 that it expects a (;) not a ({). i have tried countless times to get this to change since i assume that it is wrong and i cannot locate if i have an open brace. i count 16 braces with 8 of each type so im stumped. PS. this is a hw assignment but just need this one problem checked. teacher hasnt responded.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
void calculate_norm(float mine[][3]);
const int ROWS = 5;
const int COLS = 3;
int main(){
ofstream Create("problem1.txt");
int x;
for(int x = 1; x <16; x++){
Create << x << endl;
}
ifstream MyMatrix("problem1.txt");
float mine[ROWS][COLS];
cout << "Input Matrix: " << "\n" << endl;
for( int R = 0; R < 5; R++){
for( int C = 0; C < 3; C++){
MyMatrix >> mine[R][C];
}
}
for( int R = 0; R < 5; R++){
for( int C = 0; C < 3; C++){
cout << setw(6) << fixed << setprecision(2) << mine[R][C] << " ";
}
cout << endl;
cout << "\n";
}
void calculate_norm(float mine[][3]){ (this is line 33)
float R, C, max, length;
for (R = 0; R < 5; R++) {
for (C = 0; C < COLS; C++){
So I went ahead and reworked my code to not define a function in my main. Thank you all. But now my calculate_norm function seem to now even do anything. I manipulated the code so that it will run and display the way it is supposed to but the calculations are not being performed. What may I be missing.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
float calculate_norm(float mine[][3]);
const int ROWS = 5;
const int COLS = 3;
int main(){
float length;
ofstream Create("problem1.txt");
int x;
for(int x = 1; x <16; x++){
Create << x << endl;
}
cout << "Input Matrix:" << endl;
ifstream MyMatrix("problem1.txt");
float mine[ROWS][COLS];
for( int R = 0; R < 5; R++){
for( int C = 0; C < 3; C++){
MyMatrix >> mine[R][C];
}
}
for( int R = 0; R < 5; R++){
for( int C = 0; C < 3; C++){
cout << setw(10) << fixed << setprecision(2) << mine[R][C];
}
cout << endl;
cout << "\n";}
cout << "Maximum Row : " << "4" <<endl;
cout << "Length: " << "24.29" << endl;