# input/output

• 11-25-2006
Kevineze
input/output
currently wrote a bank account type code it compiles well but instead of givign a starting bank account of 40 when i run it it gives a starting bank account of 22 + the deposit. I also tryed usign a const for the starting bank account so i just did bank == 40. take a look at the code
think im starting to get the hang of this another week or two practicing code n ill move up :)

Code:

```#include <iostream> using namespace std; int main () {   int i;   int bank;   bank == 40;   cout<<"You have 40 dollars in your account" << endl;   cout << "Enter how much money you want to deposit: ";   cin >> i;   cin.ignore();   cout << "You have " << bank + i <<" in your account "<< endl;   cout << " and an interest rate of " << (bank + i) * .05 <<" per month "<< endl;   cin.get(); }```
• 11-25-2006
Kevineze
heres better example of code maybe thsi will help give u an idea of what im talking about. I declare bank as 40 but keeps sayign its 22. why is this?

Code:

```#include <iostream> using namespace std; int main () {   int i;   int bank;   bank == 40;   cout<<"You have "<< bank << "dollars in your account" << endl;   cout << "Enter how much money you want to deposit: ";   cin >> i;   cin.ignore();   cout << "You have " << bank + i <<" in your account "<< endl;   cout << " and an interest rate of " << (bank + i) * .05 <<" per month "<< endl;   cin.get(); }```
• 11-25-2006
ZuK
Quote:

Originally Posted by Kevineze
I declare bank as 40 but keeps sayign its 22. why is this?

Code:

`  bank == 40;`
This statement has no effect. it just checks if bank is 40 and discards the result of the comparison.
it should be
Code:

`  bank = 40;`
Kurt
• 11-25-2006
Kevineze
how do I make the statement take effect?
Ok sry didnt notice the == vrs the = there lol I got It its working now thanks.
• 11-25-2006
Sentral
Quote:

Originally Posted by Kevineze
how do I make the statement take effect?

What? He just showed you.
Code:

`bank==40`
Is comparing, not assigning the value of 40. You want to use
Code:

`bank=40`
If this is going to be constant, use:
Code:

`const int bank;`
Also, don't post stupid short statements, use the edit button for that.
• 11-29-2006
dwks
Quote:

If this is going to be constant, use:
Code:

`const int bank;`

Remember to initialize constants . . .
Code:

`const int bank = 40;`