Keywords in C

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.


const can be used to declare constant variables. Constant variables are those variables which once initialized, can’t change their value which means the value assigned to them remains unmodified.


The static keyword is used to declare static variables. These variables have a property of preserving their value even after they are out of their scope. Hence, static variables preserve the value of their last use in their scope. So they are initialized only once and exist till the termination of the program. This means that no new memory get allocated as they are never re-declared. Their scope is local to the function to which they were defined. Global static variables can be accessed anywhere in the program. By default, they are assigned the value 0 by the compiler.


If extern is used to declare a variable, then it means that the variable is defined elsewhere and not within the same block where it is used. So an extern variable is nothing but a global variable initialized with a legal value where it is declared in order to be used elsewhere. It can be accessed within any function/block of the program.


Void is a special data type only. Void means an empty data type. It means it has nothing or it holds no value. When it is used as the return data type for a function, it simply represents that the function returns no value. 


It is used to create a new data type which is equivalent to the existing data type. From then, the new data type can be used to declare variables.


Variables in C

A variable is an identifier used to represent a single data item whose quantity (or) value may vary during program execution. Variable names are the names given to memory locations where the values are stored. In C language, the data type associated with a variable cannot change. The data item corresponding to the variable can be accessed by simply mentioning the name of the variable.

But before using variables in the program, the compiler should be informed well in advance about two things

  1. such a variable will be used in the program (eg., ‘a’ and `13′)
  2. the type of data which the variable can hold.

Add Your Heading Text Here

Open chat
Need help?
Welcome to MAD Learning!

How can we help you?