What is the Variables in C Language ???
A Variables in C is a specifically defined area of memory where a value is stored. These values can come from of several data types, including characters, integers, and floating-point numbers. And it’s name show it’s value is changed during the execution of the program.
Let’s explore variables – How We Declare it, How we initializing the Variables and Assigning the values,
Step – 1 : Declaring a Variables
Declaring a variables is process which is used to specify the name and data type of the variables.
int num;
- Here we write int num; which we used to declare an integer variable, with a name Variable “num”.
Step – 2 : Initializing a Variables
Initializing a Variables means giving a starting value to the variable. Like if you want initialize a value of variables is 0. Then we write,
num = 0;
Step – 3 : Assigning a Variables
Assigning a Variables meaning is the giving new value to the variables. And it is Writing anytime when execution of program. Like if I want to assign a “10” to “num” then we write,
num = 10;
Example: Variables
Let’s take an example of Variables to understand the Variables Declaration, Initialization, and Assigning.
#include <stdio.h> int main() { // Variable Declaration int num; // Variable Initialization num = 0; // Variable Assignment num = 10; // Printing the value of variable printf("Value of num: %d\n", num); return 0; }
C Language E-book
Explanation about Program
- First, we declare a Integer Variable “int num”.
- Second, we initialize a “num” with 0 and write this – “num = 0”.
- Third, We assign a “num” with 10 and write this as like – “num = 10”, Final Value.
- Lastly, Write a “printf(“Value of num: %d\n”, num);” – which is used to print a value of variable “num”.