C Variables
C Variables
In this tutorial, we will learn about C Variables. Variable names are names that refer to computer memory locations. ( RAM: Random Access Memory). We can use simple human-readable variable names to store and access the program data. Programmers do not need to remember or use the actual memory address in order to store or retrieve data.
C Variables
We can store data in the variables and access them to perform calculations in the C program. Before using the variable in the C program we need to declare the variable.
Variable declaration
When you define a variable in a C program, we must tell the C compiler the variable name and what kind of data or data type of the variable it will hold.
For example integer, float, double, char, bool, etc.
Declare Single Variable
The general syntax of the variable declaration in C is as follows:
<data_type> <variable_name>;
Examples
int number;
In this example, we have declared an integer variable called number. The variable can store whole numbers.
Let’s declare another variable. In this example, we have declared interestRate variable of double datatype.
double interestRate;
double area;
Declare Multiple Variables
We can also declare multiple variables of the same data type using a single statement:
double length, width, area;
—
C Tutorials
C Tutorials on this website can be found at: