Variables Of C Programming Language

aimtocode

Definition Of Variable

A variable is an identifiers used to represent some specified type of information.

A variable represents a single data item, that is, a numerical quantity or a character constant etc.

The data item must be assigned to the variable at some point in the program. the data item can then be accessed later in the program simply by referring to the variable name.

The information represented by the variable can change during the execution of the program by assigning different data items at various places within the program. But the data type associated with the variable cannot change.

Variable Declaration:

Before a variable is used in a c program, it must be declared. This involves notifying the compiler of the variable's name and type as follows : type name; Where type can be int if the variable is going to hold an integer value, char if this to be a character variables, or float if this is a floating-point variable.

The following is an example of variable declaration : int var_name ; in the above example, the name of the variable is var_name and it is a type of int.

Variable Type Description
char One-character value, non-numeric; e.g., a
int Numeric whole number; e.g., 1, -15, 0
float Floating-point number; e.g., 3.2435
double Double-precision floating point; e.g., 0.34531532343
void Use by a function that does not provide a return value

Storage Size of Variables

A variable is a placeholder in the computer's memory. When a new variable is created in C program, the program allocates memory based on the data type of variable.

Variable Type Size
char 1 byte
int 2 to 4 bytes
float 4 bytes
double 8 bytes

types of variables in C,

aimtocode