Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted (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 by Bignose

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.