• 01-26-2010
jljg23
Error E2451 C:\algorithim.cpp 18: Undefined Symbol 'cout' in function main.
Error E2451 C:\algorithim.cpp 19: Undefined Symbol 'endl' in function main.
Error E2451 C:\algorithim.cpp 22: Undefined Symbol 'cin' in function main.
Any Suggestions?

/*Question 5 Program*/

int main()

{
int A;
int B;
int C;
int D;
int E;
int F;
int G;
int N;
int P;
int S;
int T;

cout << "My first algorithim program.";
cout << endl;
cout << "Please enter pay rate";
cout << endl;
cin >> A;

cout << endl;
cout << "Please enter number of hours worked for this week.";
cout << endl;
cin >> B;

cout << endl;
cout << G = A * B;
cout << "Income before taxes.";
cout << A * B;

cout << endl;
cout << T = G * .14;
cout << N = G - T;
cout << "Income after taxes.";
cout << G - T;

cout << endl;
cout << C = N * .10;
cout << "Income spent on clothes and other accessories.";
cout << N * .10;

cout << endl;
cout << D = N * .01;
cout << "Income spent on school supplies";
cout << N * .01;

cout << endl;
cout << F = C + D;
cout << E = G - F;
cout << S = E * .25;
cout << "Income spent on savings bonds.";
cout << E * .25;

cout << endl;
cout << P = S * .5;
cout << S * .5;

return 0;
}
• 01-26-2010
whiteflags
Make sure you know the arithmetic operators of C++. Multiplication is not x, like you learned in school, it is an asterisk. The = sign always assigns to the left side as well.

It is also really helpful to develop good habits early. Consider not using one-letter names and using words like gross, hours, and wage.
• 01-26-2010
jljg23
thanks for the help, ill try to use that from now on
• 01-26-2010
jljg23
i am still getting the same error message though when i try to compile this updated program
• 01-26-2010
hk_mp5kpdw
Code:

`int main();`
Something wrong there. Also, use [code][/code] tags when posting code samples.
• 01-26-2010
jljg23
thanks for that, now that problem is fixed but more error codes just came up.
Error E2451 C:\algorithim.cpp 18: Undefined Symbol 'cout' in function main.
Error E2451 C:\algorithim.cpp 19: Undefined Symbol 'endl' in function main.
Error E2451 C:\algorithim.cpp 22: Undefined Symbol 'cin' in function main.
any suggestions?
• 01-26-2010
jeffcobb
Try including iostream.
• 01-26-2010
jljg23
yeah that didnt work either, it said it couldnt include iostream
• 01-26-2010
cs_student
Did you put
Code:

`#include <iostream>`
at the top of your source file? (it might not be in your path)

Also, remember that cout and cin are in namespace std.
• 01-26-2010
dhardin
Code:

```#include <iostream> using namespace std;```
try adding that at top of code.

also, are you giving us the full program? (just wanted to make sure you were including the right header files and all...)
• 01-26-2010
Lithorien
Quote:

Originally Posted by dhardin
Code:

```#include <iostream> using namespace std;```
try adding that at top of code.

also, are you giving us the full program? (just wanted to make sure you were including the right header files and all...)

Oh please don't teach "using namespace std". That's a wonderful way to pollute the global namespace.

Try "using std::cout", "using std::endl", and "using std::cin" if you have to use a using statement.
• 01-26-2010
jerimo
Why not, does it change anything?

Im new so its just a question