Variables Constants and Keywords in C Programing

In this tutorial, you may find out about variables, constants and keywords in C.

Variables in C

In a typical program, we’ve to try and do loads of computation. after all, there’ll be storing of some information in numerous locations of memory in laptop. These memory locations are known by their address like 56234.

Suppose if a computer programmer desires to access the actual locations like ten times in an exceedingly program to store another worth at that location.

So it’ll become a tedious job for a computer programmer if he has to be compelled to learn the numerical address name. thus to create this job simple we tend to use variables.

So variables are nothing however the name of the locations or addresses of memory that is given by a computer programmer.

Constants in C

As its name suggests constants are the values which are able to ne’er amendment throughout the execution of the program.

Sounds confusing? Let’s attempt to build things additional clear with a straightforward example.

In the higher than the image (1st) we’ve held on the constant worth three at x location. The name of that location is x. It’s a variable. we are able to conjointly store another worth at x location.

Here X = variable (location or memory address name)

3 = constant

Try to perceive the second example yourself if you have got any doubt, do comment below.

There are 2 variety of Constants

Primary constants

Secondary constants (We can learn them later)

At this stage, we are going to solely discuss primary constants. Primary constants are of 3 varieties.

Integer constants

Real constants
Character constants

Let’s discuss them one by one.

Integer Constant
Yes, it’ll contain solely integers. bear in mind associate degree number constant can ne’er contain any mathematical notation. Eg: 1, 2, -43 etc.
Character Constant

It is single (remember) alphabet, variety or associate degree special image that is clathrate in inverted commas. Eg: ‘+’, ‘1’, ‘a’, etc.

Real Constant or Floating purpose Constant

A real constant might have any digit however it should contain one mathematical notation. Eg: 1.22, -54.5, 3432.13

Types of Variables

As I aforesaid earlier variable are the name of locations in memory. therein location we are able to store any constant like number, character or Real.

however there’s some limit that associate degree number variable will solely store integer constant, character variable will solely store character constant and real variable can only store real constant.

So it’s quite obvious styles of variables is comparable types of constants. Eg: int x= 1;

Here “int” could be a keyword, “x” is associate degree number variable and it will solely store integer constant, “1” could be a number constant.
Rules for writing variable names

A variable name might contain alphabets, numbers and underscores.
No different special character (other than underscore) may be used for writing the variable name.

A variable name ought, to begin with, either underscore or alphabets.
No house is allowed whereas writing variables.

Keywords in C

Keywords are the words which mean is already explained to the compiler. they can’t be used as a variable name.

A question which can arise in your mind that, however laptop can grasp that its number variable or character variable or something else?

The simple answer is with the assistance of keywords. In one in all the higher than the example, I even have used “int” keyword. Eg: int x=1

In this example, “int” could be a keyword associate degreed it’ll tell the pc that “x” is going to be a number variable and it will solely store integer constant.

There are thirty-two keywords utilized in C language that are given below. we are going to discuss them in later tutorials.


I Love python, so I like machine learning a Lot and on the other hand, I like building apps and fun games I post blogs on my website for Tech enthusiast to learn and Share Information With The World.

Leave a Reply

Your email address will not be published. Required fields are marked *

17 − 15 =

Recent Content