Fundamentals of C Programming

Fundamentals of C Programming 

Token

Any individual entity in a c program is called as the token. There are five types of token.

1. Identifier - Identifier are the name given to any variable , function , macro, etc. They are genrally used to identify the parts of a program as suggested by its name.

for example - the name given to any function ,variable,etc

2.Keywords - Keywords are the special words that convey a special meaning to the compiler.There are total of 32 keywords in C Programming.

Some Of the Keywords are listed below :

if             void       int           float     double       long        short      else   

for           do          while      auto      char           extern     static      return   

const        signed   default    goto     sizeof         volatile   switch    register

typedef     enum    struct      union    continue     break      case       void  

3.Literal/Constants - Literals are the constants used in C Programming.These are fixed values which cannot be altered during the program.

for Example -- "feelthecoder"   this is a string literal..similarly '5' is a integer literal.

Types of Literal
  1. Integer literal
  2. Character literal
  3. String literal
  4. Floating Literal

4. Punctuators/Seprators -There are total 9 punctuation symbols in C Programming.

                                  {   }   [   ]   .    ,   (    )  '   ;  :  ?

5. Operators - Operators are the mathematical symbols which provide an ease for calculation , comparison ,etc. There are different type of operators namely airthmatic,logical,increment,decrement,etc.

!         &       |          %           ^         &&         *        -       +       ||            \       sizeof()

 

C Character Set - Characters that are used in c programming are

1.Upper Case and Lower Case


A,B,C......Z
a,b,c.........z

2.Digits


0,1,2,3,4......9

3.Graphic Characters 

+   !     @      #       $       %        ^      &      *     (       )      _       =     /      >       <     :     ;   '    "   ?  /   ^ 

4. whitespace characters

space characters , new line characters , horizontal tab ,vertical tab, and form feed.

5.Others

alert,backspace,carriage return , null character.

Escape Sequence

Some characters can not be displayed like other normal characters.So we use escape sequence
by placing backslash(\) along with other C character. 

for example
\n  -   Moves the cursor to the beginning of the next line
\t   -   Moves the cursor to the next horizontal tab
\b  -   Moves the cursor to the previous position of the current line
\a  -   Produce an audible or visible alert
\r  -   Moves the cursor to the beginning position of the current line.
\f  -   Moves the cursor to the initial position of next logical page
\0 -   Used for termination of character string
\v -   Moves the cursor to the next vertical tab position 
\\  -   Presents  a character with backslash

Trigraph Characters

Keyboards do not have all the symbols and keys.So to use such symbols C Provides trigraph characters.

It is a sequence started by ?? and ended with any character from C character set.

For Example
Tripgraph                 Symbol
??<                                 {
??>                                  }
??!                                   |
??'                                   ^
??(                                  [
??)                                  ]
??/                                  \
??=                                  #

Delimiters

Delimiters are used for syntactic purpose in C.
Some of them are listed beloew

:    -  Used for label
;    - End of statement
()  - Used in expression
[]  - Used for array

Expressions

An expression is a combination of operators ,constants,variables and function calls.expression can airthmetic ,logical or relational.

For Example

x+y        -  airthmetic expression
a=b+c    -  Uses of two operators
func(a,b)-  function call
a==b      - logical expressions
a>b        - relational expression

Statements

In C Program instructions are written in the form of statements. A statement is an executable part of program and causes the computer to carry out some action.

Types of C Statements

1. Expression Statements  (for example  a=b;)
2. Compound Statements  (for example  {.......})
3. Selection Statements     (for example if ...if  else.....switch)
4. Iterative Statements       (for example while ,for and do-while)
5. Jump Statements            (for example goto ,continue ,break, return)
6. Label Statements           (for example case,default,label statement used in goto)

Comments

Popular posts from this blog

Coding tips for Developers

Master Data Structure & Algorithms in Python

How to Start with Coding: A Beginner's Guide