+ 2

Please look at the following code and help me out

#include <iostream> int main(){ int money = 1000; int expense = 100; int balance = 1000-100; return 0; /* Now if I run this code again ,it should set money variable to 900 since I have deducted 100 from it ..how can I do this ? */ }

10th Oct 2017, 7:42 AM
suryapoojary
suryapoojary - avatar
21 Rรฉponses
+ 14
Do you mean, int money = 1000; int expense = 100; int balance = money - expense ; ? or money -= expense ; // 1000 - 100 = 900 -> current money ?
10th Oct 2017, 7:48 AM
Babak
Babak - avatar
+ 8
You will need to write your data after code is complete to a file, and then after code runs, extract the data. I don't know how to do that in C++, But you can google it .
10th Oct 2017, 7:48 AM
Meharban Singh
Meharban Singh - avatar
+ 5
it should be int balance = money-expense; not 1000-100 because this number are independent of your two other variables Also if you run a code it will be executed independently of its previous executions unless you do files stuff which... may be tricky for you in the first place Just keep following the C++ courses for now
10th Oct 2017, 7:48 AM
Dapper Mink
Dapper Mink - avatar
+ 4
As I said, a program will run independently of its previous executions unless you do some file writing/reading That also shouldn't be what you must care about as a beginner, keep learning the courses for now
10th Oct 2017, 7:56 AM
Dapper Mink
Dapper Mink - avatar
+ 4
No worry ^^ Also...... HENTAI? HOW DARE YOU?!
10th Oct 2017, 8:32 AM
Dapper Mink
Dapper Mink - avatar
+ 4
Guys chill chill this is a query question not an anime/hentai debate. (I hate both BTW ๐Ÿ˜‚๐Ÿ˜‚)
10th Oct 2017, 8:36 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 3
I'm a male just so you know :^)
10th Oct 2017, 8:29 AM
Dapper Mink
Dapper Mink - avatar
+ 3
Don't take it too seriously, I'm amused ^-^
10th Oct 2017, 8:39 AM
Dapper Mink
Dapper Mink - avatar
+ 3
Okay, since I am too serious, do you want me to say why I hate anime? ๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚
10th Oct 2017, 8:43 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 3
hating hentai Is ok y anime tho?
10th Oct 2017, 8:52 AM
Meehal ๐Ÿป
Meehal ๐Ÿป - avatar
+ 2
sorry..I looked at the hentai pic and assumed ..
10th Oct 2017, 8:31 AM
suryapoojary
suryapoojary - avatar
+ 2
Because I get so frustrated over how my schoolmates react over it
10th Oct 2017, 8:53 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 2
I don't mind tbh I pretty much don't watch animes But calling my profile pic "hentai" is like calling a picture of my sister "porn"
10th Oct 2017, 8:57 AM
Dapper Mink
Dapper Mink - avatar
+ 2
You did
10th Oct 2017, 10:47 AM
Dapper Mink
Dapper Mink - avatar
+ 2
This might be something you could start with. It works on a pc. Sadly not on mobile yet. https://code.sololearn.com/ctXBnx3kJzNX/?ref=app
11th Oct 2017, 4:42 AM
Bob
Bob - avatar
+ 1
alright ...thank you all for your suggestions but I'm stuck at ...now it will return 900 right ...but when I exit the program it will set to 1000 again..I want to solve it ..
10th Oct 2017, 7:53 AM
suryapoojary
suryapoojary - avatar
+ 1
yes ma'am :)
10th Oct 2017, 8:28 AM
suryapoojary
suryapoojary - avatar
+ 1
but hentai IS actually good ;)
10th Oct 2017, 10:15 AM
suryapoojary
suryapoojary - avatar
0
hehe..sorry ..bru ..mixed anime and hentai up I guess..
10th Oct 2017, 10:15 AM
suryapoojary
suryapoojary - avatar
0
OMG !!! Did I just say that ?!! :D
10th Oct 2017, 10:15 AM
suryapoojary
suryapoojary - avatar