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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
cpp/editing_the_value_of_variables.txt · Last modified: 2024/02/16 00:48 (external edit)

Impressum Datenschutz