Tuesday, 25 September 2012

C language basics


→Translators:
These are software that convert source code into object code that convert a language written in other then machine language into machine understandable language.
There are three types of translators:
  • Assemblers:
These are translators that convert a program written in assembly language into machine language.
  • Compilers:
These are translators that convert high level language into machine language. Compilers translate whole programs at once.
  • Interpretors:
These types of translators convert high level language into machine language but the difference between interpreters and compilers is that compilers translate whole program at once and interpreters translate programs in instructions by instructions form.
Identifiers:
A group of symbols used to represents any programming entity. Entity may be a constant variable function character etc.
→Rules for representations of an identifier:
  • Every identifier must start from an alphabet or an underscore followed by any sequence of alphabets numbers of underscores
  • Keywords are nor allowed
  • No space or any other special characters are allowed
  • Only 31 characters are significant
An identifier may be a constant or a variable
Constant:
These are identifiers whose values can’t be changed through out the program.
They are non volatile identifiers.
General form   
Const         data type         constant name= initial value
For example
Const          float                                 pi=   3.14
Types of constants
  • Integer constant:
→Whole numbers
→Without decimal point or p/q form
→May be positive or negative
→Default value will always be positive
→For example ±9  -4 +4 etc
  • Real constant:
→ Floating point numbers
→Contain decimal point
It further contain two types
  1. Fractional point number
→It has two parts
→Integer part and fractional part
→For example 54.78 has two parts
→54 is integer part and 78 is integer part
  1. Exponential point number
→It represents very small values or very large values
→It is used in scientific calculation
→Also called scientific notation of real numbers
→It also has two parts
→Mantissa part and exponent part
→4.1*10ⁿ is an exponential point number
→Here 4.1 is the mantissa part and 10ⁿ is the exponent part
→It can also be written as 4.1 e/E n
  • Character constant
Single character enclosed in single quote
‘A’   ‘r’ etc
  • String constant
One or more then one characters enclosed in double quotes
“Ali”  “54jak” etc
  • Reserved words
They are also called keywords‚ having special meaning in c language. They are used to perform a special task. There are 32 keywords in c language that’s why c language is easy to learn. They are always written in lower case.
For example if for else while etc
  • Variables;
→Volatile identifiers
→Value stored in variable can be changed
→Named memory location in which specific type of data can be stored
General form:
data type     variable name;
For example:
int                  a ;
float              average;
Variable may be
Local (that is define within the body of some function)
Formal (defined within the header of a function)
Global (defined outside all the functions)

No comments:

Post a Comment