Monday, July 27, 2009

C++ help... Due tomorrow.?

I need this program to work by tomorrow morning, but I can't tell that I'm doing anything wrong!!





Errors:


o_assignment5.cpp: In function `int main()':


o_assignment5.cpp:48: non-lvalue in assignment


o_assignment5.cpp:48: parse error before `-' token


o_assignment5.cpp:52: parse error before `)' token


o_assignment5.cpp:54: parse error before `)' token


o_assignment5.cpp: At global scope:


o_assignment5.cpp:61: parse error before `;' token


o_assignment5.cpp:61: syntax error before `++' token


o_assignment5.cpp:63: parse error before `;' token


o_assignment5.cpp:63: syntax error before `++' token


o_assignment5.cpp:66: syntax error before `%26lt;%26lt;' token


o_assignment5.cpp:70: syntax error before `.' token








Code:


#include %26lt;iostream%26gt;


#include %26lt;cstdlib%26gt;


#include %26lt;fstream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;cmath%26gt;





using namespace std;





const int SIZE = 15;


int colRow[SIZE][SIZE];


int userRow; // what the user of the program inputs for table width


int finalRow;


int userCol;

C++ help... Due tomorrow.?
The userRow - 1 = finalRow is not correct. I think that you mean: finalRow = userRow -1 and finalCol = userCol - 1





Try that it should compile.





But also I don't understand your loop code





the "int finalRow" will override the previously defined "finalRow" for the scope of the loop and likewise for the "int finalCol" loop.





HTH
Reply:userRow - 1 = finalRow


userCol - 1 = finalCol





Switch to


finalRow = userRow - 1


finalCol = userCol - 1
Reply:1. Look at your assignments for userRow and userCol from finalRow and finalCol





2. Your last loop isn't going to do what you intend it to.





Good luck.
Reply:1. You redeclared "outs" inside of main() ...don't do that.





2. Look at the following two lines:


userRow - 1 = finalRow // to get right number in array: rows


userCol - 1 = finalCol // to get right number in array: cols





You must place the variable to which a value is assigned in the LEFT side of the expression, like this: y = x - 1





3. One of your for() loops had a missing closing brace. Use proper indentation to find where this occurred.


No comments:

Post a Comment