Constant in C and Types of Constant What are the constants?

Sumant jha
3 min readJan 26, 2021

--

In the series of learning programming in C we have already discussed some basics about C, introduction to C, language structure of a C, program and execution process of a C, program the steps the translation, linking and loading model. So here we will learn about constant in C and type of constant. Let’s start what are the constants?

Before writing a program you should aware of some more concepts. And these concepts we will use while you write a program. Like constants variables will use functions, data types without these you cannot write a program. So first of all we will discuss these concepts then we will come to programs.

So now on this topic, I am going to talk about constant in the C language. All the types of constant will discuss with some examples and some rules.

To declare constants like this value is a constant and this value is not a constant means valid and invalid constants you can say.

Now let us discuss constant in c constants are having fixed values. The value of constants is not going to be changed throughout the program. You can say during the execution of a program. The values are to be fixed.

The programmer while writing a program will specify these values. This means the compiler knows the value of the constant during compile time. You will not give the value at runtime. One thing is that we use symbolic constants. So that we use to define some fixed values like supposing the value of PI. So you will write like

#define PI 3.14

This is what that definition section we have discussed when we were discussing the structure of a c program. So the value of PI is fixed at 3.14. It is symbolic constant in c. If you write suppose

#define max 50

So the value of that max is what is to be 50 throughout the program. It is not going to change. You cannot change that value. These are symbolic constant in C.

So we are having basically two types of constant in c. You can say numeric constants and character constants. Or somewhere it is also written four types of the constant integer constant, a floating-point constant, character constant and string constant.

Let us discuss so these are four types of constant or you can say two types numeric and character constant is.

Numeric is further divided into two types integer constant and real constant of floating constant. Here single character constant string constant. So basically four types. So let us discuss the first one is integer constants these are having decimal values like if you write this 10 it is a constant five integer constant. One integer constant these are valid but if you write 0 5 this is not you can say decimal constant.

Learn complete topics of constant in C.

You can also visit our institute

My Computer Institute

Address: Ground Floor, B/22, Topaz Trade Center, Tulinj Rd, opp. Janta Bazar, near Amit Dairy, Nalasopara East, Nala Sopara, Maharashtra 401209

Phone: 084465 30415 / 084465 30416

--

--

No responses yet