2. WHAT IS C(TYPES OF C CONSTANTS,RULES FOR CONSTRUCTING INTEGER CONSTANTS,TYPES OF C VARIABLES)

 Getting started with C



There is a close analogy between learning English language and learning C language.


This is illustrated in the figure Alphabets,Digits and Special Symbols

fiure show the valid alphabets,number and special symbols allowed in C.Constants,Variables and Keywords.

The alphabets, digits and special symbol when properly combined form constants, variables and keywords. 

A constant is an entity that doesn't change,whereas, a variable is an entity that may change.A keyword is 

a word that carries special meaning.In the programming languages, constants are often called literals, whereas 

variaves are called identifiers.Let us now see what different types of constants and variables exist in C.


<<<....TYPES OF C CONSTANTS...>>>

Constants in C can be divided into two major categories:

(A)Primary Constants

(B)Secondary Constants

These constants are further categorized below figure....>>>




At this stage,  we would restrict our discussion to only Primary constants,namely ,Integer,Real and Character constants.

Following Rules have been laid down for constructing these different types of constants:

<<<...RULES FOR CONSTRUCTING INTEGER CONSTANTS...>>>

A.An integer constants must have at least one digit.

B.It must not have a decimal point.

C. It can be any of zero,positive or negative.If no sign precedes an integer constants,it is assumed to be positive.

D.No commas or blanks are allowed within an integer constant.


<<<...RULES FOR CONSTRUCTING REAL CONSTANTAS...>>>


Rea constantanats are often called Floating Point constants. Real constantants could be written in two forms-

Fractional form and Exponential form.Following rules must be obeserved while constructing reall constants expressed in 

fractional form

(A)A real constants must have at least one digit.

(B)It must have a decimal point.

(C)It can be either positive or negitive.Default sign is positive.

()D)No commas or blanlks are allowed within a real constant.

 The exponential form is usually used if the value of the constant is either too small or too large.

It , however,doesn't restrict us in any way form using exponential form for other real constants.


In exponential form , the real constant is represented in two parts.The part appearing before 'e'

is called mantissa, whereas the part following 'e' is called exponent.



Following rules must be observed whiile constructing real constants expressed in exponential form:


(a)The mantissa part and the ecxponential part should be separated by a letter e or E.

(b)The mantissa part may have at least one digit,which may be a positive or negative integer.


<<<...RULES FOR CONSTRUCTING CHARACTER CONSTANTS...>>>


A. A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted  commas.

B. Both the inverted commas should point to the left.


<<<...TYPES OF C VARIABLES...>>>



A particular type of variable can hold only the same type of constant.For example , an integer variabe can hold only an integer

constant, a real variable can hold only a real constant and an character variable can hoe only character constant.


In any C program many calculations are done . The results of these calculations are stored in some cells(locations) of computer's

memory. To make the retrieval and usage of these values easy, the memory cells are given to these locations are called variable names.



FOLLOW ME .....>>>>>



Post a Comment

0 Comments