Getting started with C | C Language

getting started with C
Getting started with C




 

Getting started with C

C is a programming language. C Language Designed and written by Dennis Ritchie, in AT & T's Bell laboratories of U.S.A. in 1972.

Question: why  C  seems so popular ? 

Ans: because it is reliable, simple and easy  to  use. Moreover, in an industry  where  newer languages, tools and technologies emerge and vanish day  in  and day out, a language that has survived for more than 3 decades has to be really good. 

 

Program    

 A group of instructions can then be combined to form a program.

 Identifier:

1. Constant:- A Constant is an entity that doesn't change.

2. Variables:- Variables are the name of memory locations where we store data. It may change.   

3. Keywords:- A keywords is a word that carries special meaning. There are 32 keywords in C Language.

 

Type of Constants in C

It is devided into two major categories :

  1. Primary Constants

  2. Secondary Constants

 
constants in C

   

Rules for constructing Integer Constants

  1.  An integer constant must have at least one digit.

  2. It must not a decimal point.

  3. It can be zero, positive or negative.

  4. If there is no sign precades an integer constant, then it is assumed to be positive (+).

  5. No commas or blanks are allowed within an integer constant. Example: Sum (),  Su,m or S u m (X)

  6. The allowable range for integer constant is : (-2147483648 to +2147483648). But this range is depend on compiler.

        example: 583, +736, -42675

 

 Rules for constructing Real Constants

  •  Constructing Real constant expressed in fraction form

  1. A real constant must have at least one digit.

  2. It must have a decimal point.

  3. It could be positive or negative.

  4. Default sign is positive(+).

  5. No commas or blanks are allowed within an real constant.

     example: +452.768, 763.00, -76.53, -845.9654.


  •  Constructing Real constant expressed in exponential form

  1.  Mantissa part and exponential part should be separated by a letter which is e or E.

  2. The mantissa part may have a positive or negative sign.

  3. Default sign of mantissa part is positive.

  4. The exponent must have at least one digit , which must be a positive or negative integer. Default sign is +ve.

  5. Range of real constant expressed in exponential form is : (-3.4e38 to +3.4e38).

Note:-  The part appearing before e called mantissa.         

Example: 0.000563 can be written as-  5.63e-4 (It means 5.63 x 10-4 ). 



Rules for constructing Character Constants

  1.  A Character constant is a single alphabets, a single digit or a single special symbol enclosed within single inverted comma.

         example:  'A' , 'T' , '8' , '=' etc.




Rules for constructing Variable Names

  1. A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some Compilers allow variable name whose length could be upto 247 characters.

  2.  The first character in the variable name must be an alphabet or Underscore ( _ ).

  3. No special symbol other than an underscore can be used in a variable name.

  4. No commas or blanks are allowed within a variable name.

    Example: add_number , avg_of_3 etc.

 

NOTE: 

  •   * Always creat meaningful variable names otherwise you will confuse with the variable names. 

 example: prin(Principal) , roi(rate of interest) , noy(number of years) etc.

 

  •  * This type declaration done at the beginning of the program as shown below.

       Ex:     int  si, c_i;

             float  bassal;

             char  code;


C Keywords

Keywords are the words whose meaning has already been explained to the C compiler. We can't use keyword as variable name because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the computer.

There are 32 Keywords available in C Language.

 
Getting started with C, C keywords
C Keywords

 
 

Post a Comment

0 Comments