Variables in C Flashcards
What is a variable?
References to memory locations
Allow us to use names rather than memory addresses to access and manipulate data
Types of variable
char
int
double
float
Variable type qualifiers
signed - can hold positive and negative numbers
unsigned - can only hold positive numbers
short - –32768 to 32,767
long - –2,147,483,648 to 2,147,483,647
sizeof() does what?
used to check the size of a variable in bytes
Where must variables be declared?
They must be declared in the variable declaration section before use AT THE START OF THE FUNCTION AND BEFORE ANY STATEMENTS
What is the value of a variable if it has been declared but not been assigned a value?
Most compilers set the value to 0 and this zero is constant
What is a constant?
A constant is a variable whose value cannot be modified and is essentially read-only