Thursday, 16 January 2014

WHAT IS C LANGUAGE COMPONENTS


C Language Components

The four main components of C language are
1) The Character Set.
2) Tokens
3) Variables
4) Data Types


1) The Character Set :


 Character set is a set of valid characters that a language cab recognize. A character represents any letter, digit or any other sign.

* Letters           - A,B,C……Z or a,b,c …………z.

* Digits        -      0,1…………9

* Special Symbols        -      ~!@#$%^&.........

* White Spaces        -        Blank space, horizontal tab, carriage return,
new line, form feed.


2) Tokens: 

The smallest individual unit in a program is known as a token.
C has five tokens

i. Keywords
ii. Identifiers
iii. Constants
iv. Punctuations
v. Operators


i. Keywords:

 Keywords are reserved word in C. They have predefined meaning cannot changed. All keywords must be written in lowercase. Eg:- auto,long,char,short etc.

ii. Identifiers: -

 Identifiers refer to the names of variable, functions and arrays. These are user-defined names. An identifier in C can be made up of letters, digits and underscore. Identifiers may start with either alphabets or underscore. The underscore is used to make the identifiers easy to read and mark functions or library members.

iii. Constants: -

 Constants in C refers to fixed values that do not change during the execution of a program. C support several types of constants.
a. Numerical Constants
i. Integer Constant
1. Decimal Constant
2. Octal Constant
3. Hexadecimal Constant
ii. Float Constant
b. Character Constants
i. Single Character Constant
ii. String Constant

Integer Constant: -

 An integer constant is a whole number without any fractional part. C has three types of integer constants.
Decimal Constant: - Decimal integers consists of digits from 0 through 9
Eg.: 34,900,3457,-978

Octal Constant: -

 An Octal integer constant can be any combination of digits from 0 through 7. In C the first digit of an octal number must be a zero(0) so as to differentiate it from a decimal number. Eg.: 06,034,-07564

Hexadecimal Constant:

 Hexadecimal integer constants can be any combination of digits 0 through 9 and alphabets from „a‟ through „f‟ or „A‟ through „F‟. In C, a hexadecimal constant must begin with 0x or 0X (zero x) so as to differentiate it from a decimal number. Eg:- 0x50,0XAC2 etc

Floating Constants (Real):

 Real or floating point numbers can contain both an integer part and a fractional part in the number. Floating point numbers may be represented in two forms, either in the fractional form or in the exponent form.
A float point number in fractional form consists of signed or unsigned digits including decimal point between digits. E.g:- 18.5, .18 etc.
Very large and very small numbers are represented using the exponent form. The exponent notation use the „E‟ or „e‟ symbol in the representation of the number. The number before the „E‟ is called as mantissa and the number after forms the exponent.
Eg.:-5.3E-5,-6.79E3,78e05

Single Character Constant: -

 A character constant in usually a single character or any symbol enclosed by apostrophes or single quotes. Eg.: ch=‟a‟
String Constant: - A sequence of character enclosed between double quotes is called string constant. Eg.: “Hello Good Morning”

iv) Punctuations: -

 23 characters are used as punctuations in C. eg: + _ / ; : > ! etc

v) Operators: -

 An operator is a symbol that tells the computer to perform certain mathematical or logical manipulation on data stored in variables. The variables that are operated as operands. C operator can be classified into 8 types.
i. Arithmetic Operators : + - * / %
ii. Assignment Operators : =
iii. Relational Operators: < > <= >= == !=
iv. Logical Operators:! && ||
v. Conditional Operators: ! :
vi. Increment & Decrement Operator : ++ --
vii. Bitwise Operator:! & | ~ ^ << >>
viii. Special Operator :

4 comments: