What is constant, variable, keywords. in c language.

                                types of c constant

                                        C constant have two major categories.
                                         1) primary constant.
                                         2)secondary constant.
                                                     

                                                   c constants

         primary constant                                   secondary constant

  • integer const                                                            array          
  • real const                                                                 pointer
  • character const                                                       structure 
  •                                                                                  union
  •                                                                                  enum etc.  



constant in c language , constant ,variable and keyword in c language

TWO TYPES OF CONSTANT.

    At this starting c language we only understand  the primary constant, which is integer, real, charcter constants.

                         RULES FOR CONSTRUCTING  INTEGER CONSTANT. 

a)  An integer constant must have at least one digit.

b) It must not have a decimal point.

c) It can be either positive or negative.    

d) if no sign precedes an integer constant, it is assumed to be positive.

e)  No commas or blanks are allowed within an integer constant.

f) The allowable range for integer constant is -2147483648 to +2147483647.

  •          Integer constants must be depend on the compiler.
  •          For visual studio,gcc it is -2147483648 to +214748364.
  •          For compiler like turbo c and c++  the range is -32768 to  32767.  

                                     some example.

 143   (allowable)               48,547(comma is not allowed)                                          

+1431(allowable)               47 485(space is not allowed)

-1431( aloowable)


                       RULES FOR CONSTRUCTING REAL CONSTANT

Real constants are also known as  floating  point  constants.the real constants could be written in two forms.

1) Frictional constant

2) Exponential form

                                                     FRICTIONAL FORM

a) A real constant must have at least one digit.

b) It must have a  decimal  point.

c) It could be either positive or negative.

d) By default sign is positive.

e)  no commas and blanks are allowed within a real constant.

                                
                                                     some example
143.00(allowable)                               143(decimal is essential )
+143.17(allowable)                              14  782(blank is not allowed )
-143.17(allowable)                               14,785(comma is not allowed)



                          exponential  form .

       In exponential form the real constant. the real constant  is represented in two parts. the part appearing before 'e' is called mantissa. whereas the part following 'e'  is called exponent.Thus 0.00789 can be written in exponential  as 7.89e-4.
 following rules must be observed while constructing real constants expressed in exponential form:

a) The mantissa part and the exponential part should be separated by a letter.
b) the mantissa   part may have a positive  or negative sign.
c) Default sign of mantissa part is positive.
d) the exponent  must have at least one digit which must be a positive or negative integer.
e) Default sign is positive.

 Range of real constant exponential  form is -3.4e38 to 3.4e38.

                                            some example
+7.2e-8
8.2e8
-0.2E+3
-5.8e-5

                   

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. for example , 'A' is a valid character constant whereas 'A' is not.


                                         Example

1)'A'
2)'B'
3)'1'
4)'='


                          Types of variables

             A particular type of variable can hold only the same type of constant. like An integer variable can hold only an integer constant, a real  variable can hold only a real constant.The rules for constructing different . however ,for constructing variable names of all types, the same set of rules applies.



variable in c language, constant and keyword in c language

variable in c language

                              RULES FOR CONSTRUCTING VARIABLE NAMES

a) A variable name is any combination of 1 to 31 alphabets, digits or underscores. some compilers allow variable names whose length could be up to 247 character. still, it  would be safer to stick to the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your typing effort.b) The first character in the variable name must be an alphabet or underscore.c) No commas or blanks are allowed within a variable name.d) No special symbol other than an underscore can be used in a variable name.

                                               Example

1) bh_arat
2) b_harat
3) bh_ar_at

  • These rules remain same for all primary and secondary variables.
  • The maximum allowable length of  a variable name is 31 character, an  enormous number of variable name can be constructed using the above mentioned rules.it is good habit by using meaningful variable names.


                                              C keyword's 

  •             Keyword are the words whose meaning has already been explained to the c compiler. some compiler allow you to construct variable names that exactly resemble the keywords. however , it would be safer not to mix up the variable names and the keywords. the keywords are also called 'Reserved Words.'

  •             There are only 32 keywords available in c .it has been suggested by the ANSI committee that every such compiler specific  keyword should be preceded by two underscores not every vendor follows this rule.   
keywords in c languages, constant and variable in c language

keywords  in c languages


    



 





                     




Previous
Next Post »
}; //]]>