Assigning values to variables in C Programming
Variable
Variables in C |
Variables in c programming language are the named memory location. A variable are often defined as a storage container to carry values of an equivalent data type during the program execution.
Every variable must have a data type that determines the range and sort of values be stored.
The subsequent are the principals to specify a variable name:
1.Variable name should not start with a digit
2. Keyword should not be used as variable names.
3.A variable name should not contain any symbols except underscore(_).
4.A variable name can be of any length but compiler considers only the first 31 characters of the variable name.
Declaration of Variable
Declaration of variable tells the compiler to allocate the required amount of memory with the specified variable name and allows only specified data type values into that memory location.
Declaration Syntax:
datatype variableName;
Example:
int number;
// show code declaration of variable and print it
code:
#include<stdio.h>
void main()
{
int number=6;
float num=8.9;
printf("%d",number);
printf("\n%f",num); // in c programing "\n" use to go new line
}
output:
6
8.900000
--------------------------------
Comments
Post a Comment