Math, Operators and Type Conversion
Selection
Random Numbers
100

Any individual item or combination of items, like variables, literals, operators, and parentheses, that evaluates to a value.

Expression

100

The C language will always pair an "else" statement with the last if statement not isolated using braces.

The Dangling Else Problem

100

"Seeds" the random number generation. Seed determines what random numbers are generated during runtime of the program.

srand()

200

int x = 1/2 * 3 * 5;

x = 0

200

There is only one case when the outcome is true and that is when both operators are in a true condition.

The && operator.
200

Used to clamp the range of values to be generated by rand()

Modulo (%)

300

int m = 10; 

int n = --m * m--;

m = 8

n = 81

300

Code equivalent of testing if x is between 30 and 50 (inclusive).

if(x >= 30 && x <= 50)

300

Name of the macro that defines the biggest value rand() can return

RAND_MAX

400

Data truncation is a consequence of this idea.

Type Demotion

400

Use when your conditions involve a single variable being compared to a finite set of constant, discrete values.

switch statement

400
Generates random numbers between 0 and 297

rand() % 298

500

The only arithmetic operator that doesn't automatically work with floats/doubles

Modulo (%)

500

int a = 3

switch(a)

{

    case 1:

       printf("1");

       break;

    case 3:

        printf("2");

    default:

        printf("default");

        break;

     case 2:

         printf("3");

}

2default

500

Generates random numbers between -50 and 50.

(rand() % 101) - 50;

M
e
n
u