Constants Variables and Keywords in C programming

Alphabets, Numbers and Special symbols like underscore are combined to form constants variables and keywords in C programming.

Constants Variables and Keywords in C programming

Constants

A constant as the name indicates is an entity that doesn’t change. We can classify the constants in to integer
constants, real constants and character constants. An integer constant is a whole number. Like 28, 102 or 857. The real constants are the numbers with the decimal value. it may be like 25.024 or 100.05 etc.

A character constant is a single alphabet or a digit or a symbol written in the single quotes. for example a written in single quotes, then A , z, + or 9. These are the character constants.

Variables

A variable as the name indicates is an entity that does change. In programming we have to store the result of calculations.  These results are stored in computer memory. The computer memory is consisting of lots of small memory cells. And each memory cell has its own address. As you can see in the below figure, 684521 is the address of the memory cell which contains a constant 10.

computer memory cell
To make the usage of memory cell easy, we give that memory cell a name. Here x is the name given to the memory cell. 10 which is stored in the memory cell named x is a constant. Here 10 is a constant and x is the name given to that memory cell and we call it as a variable name. So the variable names are the names given to the memory locations.

As you can see here the variable name may contain some other value at later time. Before the x was containing 10 but right now its containing 50 ( see below figure).

memory cell value changes
But this 50 is a integer constant and the x is a variable because it can contain any other constant value. If it of type integer then it can contain any integer constant. So then the type of variables in memory cells can contain integer, floating point and character constants.

The type of variable is nothing but the type of constant that the variable can store. It may be integer or the floating point or the real or the character.

Keywords

By using keywords we can construct the meaningful statements in any language. Every language has its own set of keywords. These are the words whose meaning has already explained to the compiler. For example in c we use the keywords like break, for, if, int,float,char etc. But one thing we should note is keywords can not be used as the variable names. If you do that you will get error. And now we are gonna see what are the variable types and what are the keywords associated with them.

A variable type is nothing but the type of constant that the memory can store. For the integer constant we use the keyword int. for example int a. or int age where age is the variable name and int is the keyword. For real or the floating point constant we use the keyword float. for example float x. float average. For character constants, we use the keyword char. example char s or char initial.

This is about the constants variables and keywords in C programming.

Write First Program in C Language

Computer Programming class, Chapter 1 for Beginners

Different types of Programming Languages

Working of C programming language

The key point for Absolute Beginners in Programming :

This is about the introduction to the Computer programming and types of programming languages, what is its history and why you should study this C programming language. Now if you are an absolute beginner and you really don’t know about computer programming and types of programming languages and all these things, Then its good to read a book called ” Programming in ANSI C ” edition seven by Mac graw hills. Click here buy it from Amazon

Comments

comments