As you have in previous chapter what is a variable now I am going to demonstrate that how to declare and read/write into a variable.
Declare single variable
Declare more than one variable
Declare and initialize
When you make a variable. It’s known as declaration in terms of C language. Declaration request OS for claiming space on physical memory.
First value assign to a variable after declaration. What if you didn’t initialize a variable then an unpredicted value assigned which is known as garbage so initialization is mandatory for denied facing socking result.
Unpredicted value when a variable has got declared. As we know the entire program in computer must be store into memory (RAM) before get run. So when you declare a variable it takes place on RAM in the form of bits and every bit on RAM must have some garbage data renounce by previous program. So we need to set some initial value like 0 before using if not result known as garbage.
Input into a single variable
printf("Enter a number>> ");
Input muliple data into single scanf
printf("Enter a first number>> ");
printf("Enter a second number>> ");
/* Input into single scanf */
printf("Enter Two number>> ");
Input multiple data type
printf("Enter a interger number>> ");
printf("Enter a Decimal number>> ");
/* clear leyboard buffer */
printf("Enter a character>> ");