Let's get into it!
To compile C++ code you will need a debugger, the 2 most well known ones are Borland and Visual Studio C++. You can find these using Google.
Content table:
1. Data types
2. Statements
2.1. If, else
2.2. For-loop
3. Functions
4. Code example
Like any other programming language, C++ uses data types to store values and information in. Here you can find a small list of the most used data types.
Int (integer value)
Float (decimal value)
Char (a character, contains text)
Bool (boolean, true or false)
I won't discuss Vector and String here since there are endless possibilities with them and it would take quite some time to write all that down.
When you are coding and you want to store a value, you will have to know two things. First, what kind of data should the variable be able to handle? Second, what will the variable be called?
This is how you declare those four data types.
int ThisIsAIntegerValue;
float ThisIsADecimalValue;
char ThisIsACharacterVariable;
bool ThisIsABoolean;
As you can see you first write the data type, after that, it's name, and then you have to finish the declaring with a ";".
Now we have created a place we can put data in, but until now we still haven't put any in.
int ThisIsAIntegerValue = 0;
float ThisIsADecimalValue = 0.0;
char ThisIsACharacterVariable = "test";
bool ThisIsABoolean = false;
2. Statements
2.1 If, else
In the next topic I will show you how to write your first program based on these two statements.
Other then the else-statement, the if-statement can stand-alone and can only be used in one way. The else-statement can also be used in a combination of both statements. These are the two possibilities:
if (... ) else
if (... ) else if (... ) else
When you use the else-statement the two actions will never be executed at the same time. As you may have guessed, the code which should get executed when a certain action returns true has to be placed between the two brackets.
So now we know where to put the action but not yet what we can do where the points are situated. This is an example of how you would use it with a boolean.
bool test=false;
if ( test )
// test is true
/* test is true */
else
// test is false
/* test is false
The "//" sign is used to place comments in your code, as you can see you can also use the "/ *" and "* /" sign. (Without the spaces) The above code is one way to check if a boolean is true or false. But to compare all data types there are built in signs you can use, here I give you a very small list:
How to Do C++ Programming Check For The New Release in Health, Fitness & Dieting Category of Books NOW!
I hope you have learned a lot from my tutorial, if you did please have a look at a new website I have been working on, Corner computer table [http://www.cornercomputertabledesk.info/]. school computer furniture [http://www.cornercomputertabledesk.info/school-computer-furniture/] is also a website I have been working on and still an ongoing project.
cell phone watches Buy Mauviel Cuprinox Style 11 2 Inch Round
0 comments:
Post a Comment