Variable in C programming

What is variable?

Variable is an entity which can change during the program execution.


Variable is the name of the memory place, where data is stored.


Variable is just like a cup of tea.

How to create a variable

int x;
float y;
char z;

General Syntax

datatype variable_name;

As shown in the above snippet, To create a variable two things are needed...

  1. Data type
  2. Variable name

Rules for creating variable name

  1. Variable name can contains Alphabets(A-Z / a-z), Digits (0-9), and Underscore (_).
  2. Variable name must begins with an Alphabet or Underscore
  3. Spaces and Special symbols are not allowed.
  4. Keywords / Reserved words are not allowed as a variable name.
  5. Variable name should be meaningful.
  6. C is a case sensitive programming language, so age, Age, AGE all are different variables.

Some valid / invalid variable names are listed below...

Variable name Valid / Invalid
name valid
father_name valid
father's name invalid
father's_name invalid
avg. invalid
2persons invalid
person1 valid
int invalid
integer valid
intnum valid
FLOAT valid (Not good practise)
___AX valid
Previous Back to C Programming index Next


Popular posts from this blog

Program to calculate telephone bill

Sum of two numbers in go lang

Program to check a year is leap year or not.

String in golang


Arrays in C Language

Reserved Words in Java

Data types in Java

Pointers in C Language

Literals in Java