C LANGUAGE
HISTORY
Ø 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
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