Algorithms
Problem: to find the addition of two no.
Input: Value of two variable a and b.
Output: Sum of two no c.
Sequence of Steps:
1. Read a,b
2. Calculate c=a+b
3. Print “addition is” c
4. Exit
Introduction to Algorithms
Flowchart Notations
Flowchart
Ex: Draw a flowchart to find the largest no between two numbers A & B.
Ex: Draw a flowchart to find the largest of three numbers A, B, and C.
Programming Languages
A computer language is a means of communication between people and
the computer.
Types of programming languages or Categorization :
There are two major types of programming languages:
1.Low Level languages:
a)Machine Level languages
b)Assembly Language
2.High Level languages:
a) Algebraic formula type processing
b)Business data processing
c)String and list processing
d)Object oriented programming language
e)Procedural Oriented programming language
f)Visual programming
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Programming Languages
Low Level languages:
1.Machine level language: i.e. 0 or 1
EX: 0111111001
2.Assembly language: In this mnemonic code is used in place of
Binary code.
ex: START , ADD, SET.
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Programming Languages
High Level languages:
1.Algebraic formula type processing:
EX:
a) BASIC (Beginners all purpose symbolic instruction code)
b) FORTRAN ( Formula Translation)
c) PL/I (Programming Language Version 1)
d) ALGOL (Algorithmic Language)
e) APL (A programming Language)
2. Algebraic formula type processing
f) COBOL (Common Business Oriented language)
g) RPG (Report Program Generator)
3. String and list processing
h) LISP (List processing)
i) Prolog (Program in Logic)
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Programming Languages
4.Object oriented programming language:
a) C++
b) Java
c) .NET
5.Procedural Oriented programming language:
d) C
e) Pascal
6. Visual programming:
f) Visual Basic
g) Visual Java
h) Visual c++
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Generation of Computer Languages
1. First Generation Programming Language (1GL)
2. Second Generation Programming Language (2GL)
3. Third Generation Programming Language (3GL)
4. Forth Generation Programming Language (4GL)
5. Fifth Generation Programming Language (5GL)
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Generation of Computer Languages
1. First Generation Programming Language (1GL):
Typical 1GL Instruction Look Likes this:
01011101010111
2. Second Generation Programming Language (2GL):
Typical 1GL Instruction Look Likes this:
ADD 12,8
3. Third Generation Programming Language (3GL)
Typical 1GL Instruction Look Likes this:
Void main()
{
Clrscr()
demo ob;
ob.getxy;
ob.getsum();
getch(); BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
}
Generation of Computer Languages
4. Forth Generation Programming Language (4GL):
Ex: Extract all customers where “previous purchases” then more then 1000.
5. Fifth Generation Programming Language (5GL):
Ex: Artificial Intelligence(AI)
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
PROCEDURAL ORIENTED vs. OBJECT ORIENTED
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
OBJECT ORIENTED PROGRAMING CONCEPT/FEATURES
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Question
1. Compare machine language, assembly language and
high-level language?
• Compare compiler, Interpreter and Assembler?
BASIC COMPUTER ENGINEERING Prepared by: Mr. CHETAN GUPTA
Program Design
There are two ways of designing a program(algorithm) in
software development process:
1. Top -Down Design
2. Bottom-Up Design
Top -Down Design
Main program
Subprogram 1 Subprogram 2
Subprogram 1.1 Subprogram 1.2 Subprogram 2.1
Subprogram 2.1.1
Programming Paradigms (Styles)
1. Procedural Programming paradigm
2. Modular Programming paradigm
3. Functional and Declarative(Logic) Programming
paradigm
4. Object-Oriented Programming paradigm
Procedural Programming paradigm
Main program
Func 1() Func 2() Func 3() Func 4()
Func 5()
Procedural Oriented Programming
Procedural Programming paradigm
Func1()
{
- --------
- --------
}
Control is Func2() Function are Defined
transferred {
to the called - -------- Function fucn1() Called Inside the Function
function - Func1() Func2()
- --------
}
Main()
{
Func 1()
-------
Func2() Function Called Inside the main Function
--------
Func3()
--------
}
Modular Programming paradigm
Main()
{
-------
-------
-------
File 1()
-------
File 2()
--------
File3()
--------
}
Modular Programming paradigm
Object-Oriented Programming paradigm
Object 1
Object 2 Object 3
Object 4
Object-Oriented Programming approach
Characteristic or Concept of OOP
1. Class
2. Object
3. Encapsulation
4. Data Abstraction
5. Inheritance
6. Polymorphism
7. Data Hiding
Character Set
It is a valid set of characters.
Letters A-Z & a-z
Digits 0 to 9
Special + ,-, /, \, {}, [ ], = ,!, <, > ,“” ,$, &, >=, <=,
Symbol
etc
White space Space, Horizontal tab, Vertical tab,
Character
Newline
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Token
The smallest unit of a program is known as token
or lexical unit.
C ++ have following tokens:
1. Keywords
2. Identifier
3. Constant
4. Separators
5. operators
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Keywords
Keywords are the reserved word that have special meaning
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Identifiers
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Constant
Constant are the fixed valve.
Integer Constant 1000,25,35,34
Character Constant ‘a’, ‘x’, ‘p’, ‘v’
Floating Constant 99.8, 67.567, -98.65
String Constant “hello c++”, “Bhopal”
Escape sequence “”, /n
Constant
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Separators
Symbol Separator Name Description
; Semi-colon Used to terminate the c++ statement.
() Parentheses Represent the property of function parameter
{} braces Used to define a block of code of function, class
[] Bracket Used to declare array type
, comma Used to separate identifiers in c++
. dot Separate package name
= Equal to sign Used for variable initialization
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Operators
Ex: +, _,*, %
BASIC COMPUTER ENGINEERING
PREPARED BY: MR. CHETAN GUPTA
Introduction to C++
C++ is an object oriented programming language. C++ is
developed by “Bjarne Stroustrup ” at AT & T Bell laboratories
in 1983.
Features of c++:
1.Object oriented
2.Class
3.Data abstraction
4.Inheritance
5.Poltmorphism
6.Portability
7.Versatile
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Precedence & Associativity
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Precedence & Associativity
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
Precedence & Associativity
EX: 1.
int a=10, b=20, c=3, d;
1. d=a+b*d;
2. d=(a+b)*d;
BASIC COMPUTER ENGINEERING PREPARED BY: MR. CHETAN GUPTA
// this is a c++ addition program
Program Structure
//comment section
#include<iostream.h> //preprocessor directives
#include<conio.h>
Class test
{
Public:
Int a,b;
Void get_valves()
{
Cout<<“enter two values”;
Cin>>a>>b;
Cout<<a>>b;
}
};
Void main() //main function
{
Clrscr();
Test hello;
Hello.get_valess(); //body of main function
getch(); BASIC COMPUTER ENGINEERING PREPARED BY: Mr. CHETAN GUPTA
} // end of main function