Mellinia Posted October 31, 2010 Share Posted October 31, 2010 Can I write a app that keeps a certain value until it receives an input that increase or decrease it? Link to comment Share on other sites More sharing options...
timo Posted October 31, 2010 Share Posted October 31, 2010 The trick is the input, not a program that has a variable. So you'll have to be a bit more specific there. Strictly speaking, your specification is fully satisfied with the following c++ code #include <iostream> int main() { for (int value(0); value!=-1; std::cin>>value) std::cout<<"value is now "<<value<<". Enter new value: "; } I somehow doubt it is what you were asking for, though. Link to comment Share on other sites More sharing options...
Mellinia Posted October 31, 2010 Author Share Posted October 31, 2010 I require an app that keeps a value, but when i give it an input, say "A" it will decrease the value and give response "B". Can c++ be used to do that? Link to comment Share on other sites More sharing options...
Bignose Posted November 2, 2010 Share Posted November 2, 2010 (edited) Any language can do this, really. You just need to learn the specifics on how to take input and how to increment or decrement. There isn't a reasonably mainstream language that can't do this (I suspect that there are some esoteric languages where this would be a challenge, there are some pretty weird languages out there). So, you have your choice of C, C++, C#, Visual Basic, Python, Ruby, Fortran, Java, etc. etc. etc. The only question is whether this "value" needs to be persistent or not. I.e. if it needs to be stored somewhere while the program isn't running. If so, the value will need to be written and read from a file or otherwise "pickled". If it isn't one value, but a whole mess of them, I suggest a database of some sort. Edited November 2, 2010 by Bignose Link to comment Share on other sites More sharing options...
Mellinia Posted November 2, 2010 Author Share Posted November 2, 2010 It's the database. hmm..Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now