Create
Learn
Share

C++ Basics

rename
lunifer's version from 2017-12-15 02:54

Basics

Question Answer
printcout << _____;
input cin >> _____;
endlcout << _____ << endl;
\n cout << _____ \n_;
single-line comment//_____
multi-line comment/* _______ */
memorize

Variables and Data Types

Question Answer
integerint x
floating pointfloat x
literal string"x"
literal character'x'
booleanbool x = true, bool y = true
stringstring x = "___";
charchar x = '_'
memorize

Arithmetic Operators

Question Answer
additionx + y
subtractionx - y
multiplicationx * y
divisionx / y
modulusx % y
brackets(x_y)
memorize

Increment Operators

Question Answer
increase by 1x++
decrease by 1x--
prefixy = ++x
postfixy = x++
memorize

Logical Operators

Question Answer
AND operatorx && y
OR operatorx || y
NOT operator! x
memorize

Loops and Conditions

Question Answer
ifif (condition) {code}
elseif (condition) {code} else {code}
whilewhile (condition) {code}
forfor (init;condition;increment) {code}
do...whiledo {code} while (condition)
switchswitch (variable) case value 1: {code... break; ... }
memorize