Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- /*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)
- { /* this isn't required if the if statement is all on one line so the next else if I wont use them */
- 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 will 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 will 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---------------------*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment