C - Variables, Loops & Conditional Statements
C - Variables, Loops & Conditional Statements
Variables
Loops
Conditional-statements
Agenda
1. Variables in C
2. Conditional statements
3. Loops
Variables
Variables are containers
● Variables are containers for storing data values, like numbers
and characters.
● In C, there are different types of variables (defined with
different keywords), for example:
int - stores integers (whole numbers), without decimals, such as 123 or -123
char - stores single characters, such as 'a' or 'B' . Char values are
surrounded by single quotes
Declaring (Creating) Variables
● To create a variable, specify the type and assign it a value:
type variableName = value; ● type is one of C types (such as int)
● variableName is the name of the variable
int cohort_Num = 14; (such as x or myName).
● The equal sign is used to assign a value to
the variable.
cont
● You can also declare a variable without assigning the value,
and assign the value later:
// Declare a variable
int myNum;