User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







cpp:editing_the_value_of_variables

To edit the value of a variable, you use the mathematical operators +, -, /, and *. Let's create the variable jimmy and set it to nine :

int jimmy = 9;

If we want jimmy to to set to 10 we can do the following:

jimmy = jimmy + 1;

Remember this syntax: [the varaible that you want to change] = [the number or existing varaible] ;

So jimmy is the variable you want to change (to ten) and jimmy + 1 is the value that exists. Merely typing jimmy + 1 does not set the value of jimmy to 10 because to change the value of something, you must have the equal sign. It is used the same way in C++ as in mathematicals.

Because typing variable = variable + x is repetitive and annoying, the creator (all hail Bjarne Stroustrup) made

Editing in Progress

advertising
cpp/editing_the_value_of_variables.txt · Last modified: 2014/02/20 17:59 by jazpen

Impressum Datenschutz