Last active
December 19, 2015 08:18
-
-
Save tance77/5924246 to your computer and use it in GitHub Desktop.
exampel v
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //This is a variable there are int, char, float, double, bool (true false) and more | |
| /*------------------variables---------------------*/ | |
| int x = 0; //this is an integer | |
| char c; // this is a character variable | |
| bool frogs = true; //these can be set to true or fasle | |
| double a = 0; //this is just a bigger storage variable than an int. | |
| /*------------------end variables---------------------*/ | |
| /*--------------If statement Begin---------------------*/ | |
| if (x = 2) | |
| { | |
| cout << "hi"; | |
| } | |
| else if(x = 7) | |
| { | |
| cout << "this is fun"; | |
| } | |
| else | |
| { | |
| cout << "bye"; | |
| } | |
| /*--------------If statement END---------------------*/ | |
| /*--------------switch statement Begin---------------------*/ | |
| switch (c) //Case statement / switch statement pretty much like an if else statement but will only work when the right case happens | |
| { | |
| case 1: //this whill happen when the character c = 1 | |
| x = x +1; //this is the same as x++; | |
| break; //break gets you out of loops or in this case the switch statment. | |
| case 2: //this whill happen when the character c = 2 | |
| x = x - 1; //this is the same as x--; | |
| break; | |
| default: //this will happen when none of the other cases matched the given. | |
| break; | |
| } | |
| /*--------------switch statement end---------------------*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment