You are on page 1of 13

PROGRAMMING LANGUAGE:

A Programming tool/software which provide a set of instructions.


Software using which user can solve a given problem.
Software using which user can instant with a system;
Structure oriented C
Object oriented C++, .NET
Types of programming language: 1. Low level language.
2. High level language.
3. 4th level language.
1) Low level language:
1. Machine language.
2. Assembly language.
1.

Machine language consists of only 0s and 1s.

2.

Assembly language is a collection of mnemonic codes.


It needs assembler, translates assembly language instructions to machine language
instructions. This is a non portable language.

START ASSEMBLY LANGUAGE


MACHINE LANGUAGE STOP

ASSEMBLER

(Only used in assembly language)


Features:

Unstructured programming language.


In unstructured programming language program consists a set of instructions
which organize sequence order.

Low level languages are not portable languages (These languages instructions not
Portable to multiple system architecture)

Not easy to under stand.

2) High level language:


The high level languages are structure and object oriented language. Instructions are in
simple English. These are portable languages.
Features:
Structured programming languages
Instructions are in simple English.
Translators:
Interpreter: Check line by line.
Compiler: Execute the program at a time (Faster than interpreter)

C-LANGUAGE:
C language is a mid level programming language having high level language
characteristics and low level language characteristics.
Features:

C language is an embaded programming language. Used for designing embaded


softwares like Device Softwares.

Portable: Moving language instructions form one platform to another platform.


(Platform: Operating System)

Modularity: Application logic is divided into module. Each Module can be called
Collection of Programs (Each Program is a set of instructions)
These instructions are divided into No. of Sub-Routines. Each Sub-Routine is
called as a function.

Simple: It is English like language. Understanding and designing is more simple.

Applications of C-language:

System Softwares:
Compiler
Interpreter

Device Softwares
Operating Systems
Other system softwares

Application Softwares:

Database (Oracle, SQL)


Word Processor
Spread Sheet
Other Tools
Business Applications
Evaluation Complimented Mathematical Expressions Scientific Applications can
be designed by using this particular language.

C- Softwares:
Turbo C
Borland C
Microsoft C
C on Linux
C on UNIX
C on Salaries
Character set in C:
A Set of Characters used inside programming language like.
a-z (lower case)
A-Z (upper case)
0-9(Digits)
Special Characters (*, +, - , #................)
C-TOKENS:
An individual unit inside a program is called as Token.
(Token is a collection of characters)
Tokens:
1.
2.
3.
4.
5.

Key Words
Identifiers
Constants
Data types
Operators

1. KEY WORDS
Key words are Reserved Words which should be in lower case (Predefine)
Key words are language related works.
Each word is having specified meaning with in language.
There are 47 latest Key words
int, while, short, unsigned, signed, struck, enum, if, break, switch, ..etc., (up to 47)

2. IDENTIFIER
Identifiers can be called as data names.
Identifiers are used to identity data or set of instructions.
Rules of Identifiers:
1.
2.
3.
4.
5.
6.

The identifier name must start with alphabet.


There should not be a space between identifier names.(a b) //error//
It allow only one special character called under scrod ( _ )
The identifier should not be a key word.
Identifier can be in upper case or I lower case.
The size of an identifier is in 8 characters only.

3. CONSTANTS
Constants are the valves which are used in side the program.

Categories of Constants:
1. Numeric Constants.
2. Character Constants.

1. Numeric Constants:
1. Integer Constants.
2. Real Constants.
1. Integer Constants:

A Constants value having only integer part is called an integer constant. Not
having any Decimal part.

1. Binary Integer.
2. Decimal Integer.
3. Octal Integer.
4. Hexa Decimal Integer

1. Binary Integer:
Integer Representation of each value in binary format which consists of 0s and 1s.
Binary Integer consist base 2
Ex:
2
2
3

12
6-0
3-0
1-1
12 (1100)2

2. Decimal Integer:
An integer value with base 10.
Consist of digit from 0 to 9.
Ex:

Binary to Decimal
(1010)2

(From left to right)

=20x0+21x1+22x0+23x1 = (10)10
Decimal to Binary
(12)10

(From left to right)

0
1
=10 x2+10 x1 = 2+10 = 12

3. Octal Integer:
It is an integer value with base-8.
It consists of 0 to 7 digits.
The octal integers prefix is o.
Ex:

o123, o175..etc.

Decimal to Octal
(12)10
8

12
1-4

14
4. Hexa Decimal Integer:
Integer value with base-16.
Consist of digits 0-9, a-f.
Hexa Decimal integers having prefix with Ox.
Binary
Oxa=10
Oxb=11
Oxc=12
Oxd=13
Oxe=14

1010

Decimal

12

2. Real Constants:
(Floating point constant)
A Constant value having integer part as well as decimal part.
Ex:

14567.23 1.456723xe4
Value of e is equivalent to 10 (e=10)

2. Character Constant:
1. Single Character Constant.
2. String Character Constant.

1. Single Character Constant:


Single Character constant is should be expressed in single quotations ( ) which
occupy one byte.

Ex:

1, a, S. etc.

2. String Character Constant:


String is a collection of characters.
Can be
Alphabet
Numbers
Special Characters
Note: Strings are expressed in double quotations only ( )
Ex:

Ram, "123, A-1/2


(Alpha Numeric)

4. DATA TYPES
Data Types which define properties of data used in side program.
Data Type is used in order to allocate memory for data.
The memory is allocated inside the RAM.
Types of Data Types:
1.
2.
3.
4.

Single data type / Standard data type.


Derived data type.
Structured data type.
Users define data type.

1. Standard Data Types:

Each data type is one key word.


Integer Data Type
To allocate memory for integer value int which allocate the memory of 2 bytes
accept positive and negative values. The range is -32768 to +32767.
Syntax: <data type><variable>/<identifier>
<Variable> Named memory location.
Ex:

int a;
Let a=10;
2
2
2

10
5-0
2-1
1-0
10 = (1010)2

a=10
0

(Sign)

Positive 1
Negative0

15-Bits are allocated for data


1-Bit is allocated for sign (+ve or ve)
Integer Clock:
If a=32768
Then a=-32768
If a=40000
Then a=-25532

Long:
This data type takes 4 bytes of memory
Range -232 to +232
Syntax: long a;
Short:
This data type takes 1 byte of memory
Range-128 to +127.
Syntax: short a;
Signed integer:
This data type takes 2 bytes of memory
Range (-32768 to +32767)
Syntax: signed a;
Unsigned integer:
This data type takes 2 bytes of memory
Range 0 to 65535
Syntax: unsigned a;
16 bits are allocated for data because there is no memory for sign.

If a= -1
Than a= 65535
If a= -2

Than a= 65534
If a= 65537
Than a= 1

Signed and Unsigned integer are called MODIFIERS

Character data type: (char)


These are used t allocate memory for character.
Allocate memory for one byte integer.
char Allocate one byte
Range -128 to +127
Ex:

char ch;
Let ch=A;

Where ch is a variable name.


There are some ASCII values for the alphabets.
A=65
B=66
C=67
D=68
E=68
F=69
G=70
H=71
I=72
J=73
K=74
L=75
M=76
N=77
O=78
P=80
Q=81
R=82
S=83
T=84

a=97
b=98
c=99
d=100
e=101
f=102
g=103
h=104
i=105
j=106
k=107
l=108
m=109
n=110
o=111
p=112
q=113
r=114
s=115
t=116

(In between 91 to 96 there are some special characters)

U=85
V=86
W=87
X=88
Y=89
Z=90

u=117
v=118
w=119
x=120
y=121
z=122

Signed Char: Allocates 1 byte of memory


Range: (-128 to +127)
Unsigned char: Allocates 1 byte of memory
Range: (0 to +255)
This data type allocates total 8 bits for a data.
It is called as 1 byte unsigned integer.
Unsigned a;
unsigned int a;
Signed a;
signed a;

5. OPERATORS
Operators which operates in operands to define the expression or to evaluate the
expression.
Based on operands which it operates is classified into different categories:
1. Binary operators.
2. Unary operators.
3. Ternary operators.
1. Binary operators:
These are the operators which operate on two operands. Evaluation is done using
two operands.
Arithmetic Operators:
+ Addition
- Subtraction
* Multiplication

/ Division
+ & - are given equal priority
* & / are given equal priority
Ex:

a=5
b=4
c=3
d=a+b-a-c

The priority of the evolution can be changed by writing in the ( ) [Paralysis]

Ex:

a=3
b=4
c=2
d= a=b*c=11
d= (a + b)*c=14

Highest priority is given to the ( )


Relational operators:
Relational operators are binary operators.
These operators are used for comparing values.
Comparing numbers and single character constants.
Cannot compare strings.
>
<
>=
<=
==
!=

Greater than
Less than
Greater than or equal to
Less than or equal to
Equal to
Not equal

* These operators return logical values.

Ex:

--

False

--

True

a=5
b=6
c=4

d=a>b>c
0>4
0
d=0