Thursday 8 August 2013

Basic Concepts of C Language


Best Blogger Tips


CHARACTER SET:
Every programming language has its own set of characters. The characters used in C are divided into 3 categories
  1. Digits
  2. Alphabets
  3. Special characters.
TABLE SHOWS DIFFERENT ALPHABETS , DIGITS , SPECIAL SYMBOLS USED IN C LANGUAGE:


  • ALPHABETS    
  • UPPERCASE                   
  • LOWERCASE                                       
  • A-Z                            
  • a-z                  

  • DIGITS                  
  • 0-9    

  • SPECIAL                CHARACTERS                                                         
  • , COMMA
  • . PERIOD
  • : COLON
  • ; SEMICOLON
  • 'APOSTROPHE            
  • + PLUS SIGN
  • - MINUS SIGN            
  • *ASTERISK                     
  • / SLASH
  • % PERCENTAGE         SIGN
  •   & AMPERSAND
  • ^ CARAT
  • ~ TILDE
  • [ LEFT BRACKET
  • ] RIGHT BRACKET
  • { LEFT                        BRACES                                                 
  • " QUOTATION MARK
  • ? QUESTION MARK                      
  • ! EXPLAMATION   MARK                       
  • _ UNDERSCORE
  • # HASH
  • = EQUAL SIGN
  • | PIPELINE SIGN
  • < LESS THAN
  • > GREATER THAN
  • \ BACKSLASH
  • ( LEFT PARENTHESIS
  • ) RIGHT PARENTHESIS
  • } RIGHT BRACES                                           



C TOKENS:
The individual units C program are known as C tokens. We use 6 types of tokens in any C program
  1. Identifier
  2. Strings
  3. Constants
  4. Keywords
  5. Special symbols
  6. Operators
KEYWORDS AND IDENTIFIERS:
In C program every word is either a identifier or a keyword. There are 32 keywords used in C Language supported by ANSI. Keywords are the reserve words which have one or more fixed meanings and the meaning of all keywords in any circumstances cannot be changed that is why these are reserve words. All the keywords of C Language are written in Lowercase letter because In C Language uppercase and lowercase letters are significant that is different meanings. List of keywords are:


                      TABLE SHOWS DIFFERENT KEYWORDS USED IN C LANGUAGE: 


  • break
  • default
  • extern
  • int                  
  • signed
  • typedef
  • while
  • goto
  • auto
  • continue
  • enum
  • if
  • short          
  • switch
  • volatile
  • void
  • case
  • do
  • float
  • long          
  • sizeof
  • union
  • char
  • double
  • for
  • register
  • static
  • unsigned
  • const           
  • else
  • return
  • struct

IDENTIFIERS: 
Identifiers may be defined as variable name, array name , function name, class name etc.Basically identifiers are the sequence of alphabets and digits.

RULE FOR FORMING IDENTIFIER NAME:
  •  Keywords should not allow to be used as identifier.
  •  Uppercase and lowercase identifiers are different.
  •  The first character must be an alphabet or an underscore.
  •  Two successive underscores are not allowed.
  •  No special characters except underscore "_" are allowed.
  •  All succeeding characters must be either letters or digits.
EXAMPLES:
  •  int a2            VALID
  • int _a23         VALID
  • int a_257       VALID
  • float abc        VALID
  • int a__2         INVALID
  • int 2_b           INVALID
  • int char           INVALID
  • int name         VALID
  • float while      INVALID
  • float !a           INVALID

No comments:

Post a Comment