+ 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 ? */ }
21 Respuestas
+ 14
Do you mean,
int money = 1000;
int expense = 100;
int balance = money - expense ;
?
or
money -= expense ; // 1000 - 100 = 900 -> current money
?
+ 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 .
+ 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
+ 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
+ 4
No worry ^^
Also...... HENTAI? HOW DARE YOU?!
+ 4
Guys chill chill this is a query question not an anime/hentai debate.
(I hate both BTW 😂😂)
+ 3
I'm a male just so you know :^)
+ 3
Don't take it too seriously, I'm amused ^-^
+ 3
Okay, since I am too serious, do you want me to say why I hate anime? 😂😂😂😂
+ 3
hating hentai Is ok
y anime tho?
+ 2
sorry..I looked at the hentai pic and assumed ..
+ 2
Because I get so frustrated over how my schoolmates react over it
+ 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"
+ 2
You did
+ 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
+ 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 ..
+ 1
yes ma'am :)
+ 1
but hentai IS actually good ;)
0
hehe..sorry ..bru ..mixed anime and hentai up I guess..
0
OMG !!! Did I just say that ?!! :D