Jun 22, 2024
#include
directives (e.g., #include <iostream>
).using namespace std;
).int main() { }
is the entry point of the program.cin
for input, cout
for output.std::cin
and std::cout
if not using namespace.
or std::endl
for new lines.
for faster execution.int
, long
, long long
.float
, double
.char
, string
.cin
for word inputs, getline(cin, str)
for full line inputs.if (condition) { } else { }
.&&
(AND), ||
(OR).if-else
inside outer if-else
for multiple conditions.switch (variable) { case value1: //code; break; ... default: //code; }
.break
to prevent fall-through.int arr[5];
.arr[0], arr[1], ...
.int arr2D[3][5];
.arr2D[0][0], arr2D[1][4], ...
.str[0], str[1], ...
..length()
or .size()
for length of string.for (initialization; condition; increment) { }
.while (condition) { }
.do { } while (condition);
.void functionName() { }
.returnType functionName(parameters) { return value; }
.&
to pass the original, changes affect original.min()
, max()
in <algorithm>
.