# THE C ELEMENTS

### 8. CONSTANTS :

Constant : A value that anyone can’t change during execution of the program and therefore remains persistent throughout the program.

Constants can be classified into three types :

1. NUMERIC CONSTANT
2. CHARACTER CONSTANT
3. STRING CONSTANT
• ## NUMERIC CONSTANTS :

First of all, Numeric constants are the constants containing numeric digits. The numeric digits may or may not have decimal point.

The rules for defining numeric constants are :

1. At least 1 digit should be present in a numeric constant.
2. Within the numeric constant, no comma or space should be there.
3. Numeric constants can either be positive or negative but default sign is always positive.

There are two types of numeric constants :

1. INTEGER CONSTANT
2. REAL CONSTANT
• INTEGER CONSTANT :-

The whole numbers having no decimal point are Integer constants.

On the basis of different number systems, Integer constants are classified in three types that are –

1. DECIMAL CONSTANTS – 0,1,2,3,4,5,6,7,8,9         (base 10)
2. OCTAL CONSTANTS – 0,1,2,3,4,5,6,7         (base 8)
3. HEXADECIMAL CONSTANTS – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,a,b,c,d,e,f         (base 16)
• REAL CONSTANTS :-

Real constants or floating point constants are numeric constants containing decimal point. Some of the valid floating point constants are –

• 0.5
• 7.5
• 729.0
• 0.123
• 906.
• 2.9999
• ## CHARACTER CONSTANTS :

When a single character encloses within single quotes is known as a Character constant. Some valid character constants are –

• ‘5’
• ‘M’
• ‘&’
• ‘ ‘
• ‘@’

Some invalid character constants are –

• Program‘ – Invalid because only one character should be present within quotes.
• M” -Invalid because Double quotes don’t enclose single character.
• ‘ ‘ – Invalid because no character between single quotes
• U – Invalid because single quotes missing
• ## STRING CONSTANTS :

A string constant contains zero, one or more than one character. Unlike a character constant, a string constant encloses within double quotes (” “). At the end of the string, the compiler automatically places ‘\0’ or null Character at that place.

Some examples of valid string constants are –

• “Mukul Bhatt”
• “12345”
• “M”
• “0”
• ” “

NOTE – “A” and ‘A’ are different from each other. The first one is a string constant which consists character ‘A’ and ‘\0’. In contrast, the second one is a character constant which represents integer value 65.

### 9. VARIABLES :

To define a variable, it is a name that we can use to store values. Furthermore, Variables can take different values but almost one at a time. We can change values taken by variables while execution of the program.

With each variable, a data type is associated. The data type of the variable decides what type of value it will take. Some examples of valid variables are –

• int a;    //Where int is an integer data type and a is the name of the variable.
• float c;   //Where float is  floating data type and c is the name of the variable.

### 10. EXPRESSIONS :

A combination of operators, constants, variables and function calls is known as an expression. The expression can be arithmetic, logical or relational. Some examples of different types of expressions are as follows –

• x+y       – arithmetic operation
• a>b       – relational expression
• func(a, b)        – function call

### 11. STATEMENTS :

In a C program, the instructions we write are in the form of statements. Furthermore, an executable part of the program through which the computer carry out some action is therefore a statement.

The classification of statements are as follows –

1. EXPRESSION STATEMENTS
2. COMPOUND STATEMENTS
3. SELECTION STATEMENTS
4. ITERATIVE STATEMENTS
5. JUMP STATEMENTS
6. LABEL STATEMENTS

The comment lines or comments have almost specific uses in a Program. Hence, we use comments in the documentation section of a program. The General purpose of using Comments is increasing readability of the program. The proper format under which comments are written is “/*” and “*/”. One can write comments anywhere in a program except inside a string constant or character constant.

Generally, comments are of two types –

NOTE : AS A RESULT, COMMENTS CAN’T BE NESTED because we cannot write a comment inside another comment.

Hence, it was all about THE C ELEMENTS Or THE ELEMENTS OF C LANGUAGE.

For more detailed information regarding the previous post, Click on