C LANGUAGE INTRODUCTION

 

C LANGUAGE

 

HISTORY

 

 Ã˜ Structured Programming Language

 Ã˜ Portable general purpose programming Language

 Ã˜ (1970’s) - Invented & implemented by Dennis Ritchie on a DEC PDP-11(low-level PDP-7 assembler language) - Unix OS - 1972 – AT & T Bell Telephone Laboratory

 Ã˜ Earlier Version - BCPL (Basic Combined Programming Language – Ken Thompson - Bell Telephone Laboratory

 Ã˜ 1978 –C first described by Dennis Ritchie, Brain Kernighan

 Ã˜ 1983 – ANSI(American National Standards Institute) established.

 Ã˜ 1989 – December first copy of ANSI C adopted

 Ã˜ Early 1990 – First copy available – This standard adopted by ISO(International Standard Organization) – (ANSI / ISO C)

 Ã˜ C” name comes from the second letter of B”C”PL

 Ã˜ Middle Level Language( Combine high-level languages with control & flexibility of assembly language

 Ã˜ Highest Level – Ada,Modula-2,Pascal,COBAL,FORTRAN,BASIC

Ø Middle Level – Java, C, C++, FORTH

Ø Lowest Level – Macro-assembler, Assembler

 

 

FEATURES OF C LANGUAGE

Ø Flexible – High level structured Programming language

Ø Add low level features

Ø Portable ( program using for one type of computer can be use in any other type)

Ø Much faster and efficient

Ø Number of built-in functions available

Ø Extent itself

Ø Modularity

Ø Code – Reusablity

Ø Limited no.of keywords


CHARACTERISTICS OF C LANGUAGE

 

Ø Small Size

Ø Extensive use of function calls

Ø Loose Typing – unlike PASCAL

Ø Low level(Bitwise)programming readily available

Ø Pointer Implementation(extensive use of pointers for Memory, Array, Structures & Functions.

Ø It has high level constructs

Ø It can handle low-level activities

Ø It produces efficient programs

Ø It can be compiled on a variety of computers

 

STRUCTURE OF C PROGRAM

 

Documentation Section

Link Section

Definition Section

Global Declaration Section

Main() Function Section

{

        Declaration Part

        Executable Part

}

Subprogram section

 

         Function1

                .

                .                              (User Defined Functions)

                .

         Function n

 

Documentation Section

 

          Comment Line

 

Link Section

 

          It provides instructions to the compiler to link functions from the system library

 

Definition Section

 

          It defines all symbolic constants

 

Global Declaration Section

 

          Declares variables that are globally visible, inside all the functions

Main

 

          Starting point of the program

          Two Parts

                   Declaration Part - Variables

                   Executable Part – { Executable statements }

                             Closing Brace( Logical end of the program)

All statements should end with a semicolon (;).  

Subprogram section

 

          All user defined functions

 

 

C Character Set

 

Alphabets             -        A……Z, a………z

Digits                   -        0,1,2,……………9

Special Characters         -        ! # % ^ & + = ~ [ ] * ( ) - _ \ | ; : ‘ “ { } ` . @ $ < > / ?

White Spaces                 -        blank space, horizontal tab, carriage return, new line, form

Feed

(\b,\n,\t,\f,\r,\v,\a)

 

Keywords

 

          It has a fixed meanings – meanings cannot be changed

It must be written in lowercase

 

          auto            double         int               struct                            

          break          else             long            switch

          case             enum           register        typedef

          char            float            return                   union

          const           for               short           unsigned

          continue      goto            size of         void

          do               if                 static           while

 

Identifiers

          Identifiers are names given to variables, functions, arrays and other user defined objects. ( alphabets, digits, _ , first char alphabet, no special chars, case sensitive)

 

Example

BASICPAY, A0, basicpay, TOTAL_PAY, B12

VARIABLES

 

Value changes during execution time

 

          Alphabets, digits, underscore(_)

 

Syntax

 

Data_type variable_name ;

 

Int a;

Int a=10;

 

CONSTANTS

 

Value not changed during execution time

 

Numeric Constants

Character Constants

String Constants

 

Numeric Constants

 

Digits and some special characters(_)

 

Integer or fixed point

Real or floating

 

1.Integer or fixed point

                             Digits without decimal point

Ex:  32323

 

                             Integer types

                                      1.1. Long int

                                      1.2. Short int

                                      1.3. Unsigned int

 

                   2. Real or floating

                             Digits with decimal point

                                      Ex:0.0000334

                            

Real types

Any no written with one decimal point

 

Fractional form

Exponent form

 

Character Constants

 

Direct

Escape sequence or escape chars

 

Direct

                    Single character

                    ASCII sign

Single Quotation

‘A’ = 67

‘a’=97

 

Escape sequence or escape chars

                             More than one character

First character starts with backslash(\)then numeric char or

char values

 

String Constants

 

          Sequence of character

          Double quotation

“arunya”

 

 

DATA TYPES

 

Different types of data available in c language.

 

Int  - 2 bytes

Char – 1 byte

Float – 4 bytes (single precision)

Double – 8 bytes (double precision)

 

Data type modifiers

         

Signed  - positive or negative

Unsigned – positive

Short

Long

 

 

 

 

DATA TYPES

BITS

VALUES

Char (or) signed char

8 bits

-128 to127

Unsigned char

8 bits

0 to 255

Int or signed int

16 bits

-32,768 to32,767

Unsigned int

16 bits

0 to 65,535

Short int or signed short int

8 bits

-128 to 127

Unsigned short int

8 bits

0 to 255

Long int or signed long int

32 bits

-2,147,483,648 to 2,147,483,647

Unsigned long int

32 bits

0 to 4,294,767,295

Float

32 bits

3.4E-38 to 3.4E+38

Double

64 bits

1.7E-308 to 1.7E+308

Long double

80 bits

-3.4E-4932 to 1.1E+4932

 

No comments:

Post a Comment