CIS 150 Midterm 1 Spring 2017 Topic List
comments
/* */ (multi-line)
// (single line)
documentation
indentation
no tabs
four spaces per level
line after { indents one level
} line unindents one level
otherwise lines retain indentation of previous line
switch statement is an exception
include directives
iostream: input, output
iomanip: output formatting
string: to use strings
cmath: math functions
using namespace std;
data types:
int
float
double
char
bool
string (not a built-in)
quotes
" for string
' for char (only one char allowed)
variables
dataType variableName;
dataType variableName = initialValue;
const dataType VARIABLE_NAME = value;
operators
()
++ --
* / %
+ -
=
== != <= < > >=
! && ||
selection
if
if/else
switch
repetition
while
do/while
for
input
cin >> variableName;
getline(cin, variableName);
cin.ignore() (used after cin, before getline)
output
cout << value << variableName;
endl
formatting
setw(int) (goes away after following output)
fixed, showpoint, setprecision(int)
setfill(char)
functions
returnDataType functionName(parameterList) { }
parameterList = comma separated variable declarations
prototype (has ; in pace of function body)
parameters are input
function returns result (if any) as output