Upload
rajaraju
View
213
Download
0
Embed Size (px)
DESCRIPTION
vvvvvv
Citation preview
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 CObject 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 0’s and 1’s.
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 ASSEMBLER MACHINE LANGUAGE STOP
(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 software’s like Device Software’s.
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 Software’s:
Compiler InterpreterDevice Software’s
Operating SystemsOther system software’s
Application Software’s:
Database (Oracle, SQL)Word ProcessorSpread SheetOther Tools
Business Applications
Evaluation Complimented Mathematical Expressions Scientific Applications can be designed by using this particular language.
C- Software’s:
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. Key Words2. Identifiers3. Constants4. Data types5. 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. The identifier name must start with alphabet.2. There should not be a space between identifier names.(a b) //error//3. It allow only one special character called under scrod ( _ ) 4. The identifier should not be a key word.5. Identifier can be in upper case or I lower case.6. 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 0’s and 1’s.
Binary Integer consist base 2
Ex: 2 122 6-03 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)
=100x2+10
1x1 = 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 121-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 Decimal
Oxa=10 1010 12Oxb=11Oxc=12Oxd=13Oxe=14
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
NumbersSpecial 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. Single data type / Standard data type.2. Derived data type.3. Structured data type.4. 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 102 5-02 2-1
1-010 = (1010)2
a=10
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
(Sign) Positive 1Negative0
15-Bits are allocated for data1-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 memoryRange (-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 a=97 (In between 91 to 96 there are some special characters)B=66 b=98C=67 c=99D=68 d=100E=68 e=101F=69 f=102G=70 g=103H=71 h=104I=72 i=105J=73 j=106K=74 k=107L=75 l=108M=76 m=109N=77 n=110O=78 o=111P=80 p=112Q=81 q=113R=82 r=114S=83 s=115T=84 t=116U=85 u=117V=86 v=118W=87 w=119
X=88 x=120Y=89 y=121Z=90 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=5b=4c=3d=a+b-a-c
The priority of the evolution can be changed by writing in the ( ) [Paralysis]
Ex: a=3b=4c=2
d= a=b*c=11d= (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.
0 -- False
1 -- True
Ex: a=5b=6c=4d=a>b>c
0>4
0
d=0