0% found this document useful (0 votes)
3 views

Computer L-1

The document introduces Object Oriented Programming (OOP) concepts, explaining how programming languages are developed to instruct computers using binary code. It outlines the basic building blocks of a program, including instruction statements and flow control, and distinguishes between Procedure Oriented Programming (POP) and OOP paradigms. Additionally, it emphasizes the importance of algorithms as a structured approach to problem-solving in programming.

Uploaded by

progresrai7
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Computer L-1

The document introduces Object Oriented Programming (OOP) concepts, explaining how programming languages are developed to instruct computers using binary code. It outlines the basic building blocks of a program, including instruction statements and flow control, and distinguishes between Procedure Oriented Programming (POP) and OOP paradigms. Additionally, it emphasizes the importance of algorithms as a structured approach to problem-solving in programming.

Uploaded by

progresrai7
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction to Object Oriented

Programming Concepts
We all know that a computer works on human instructions. It takes
a “command” or “instruction”, works upon it and gives an output.
The language which a computer can understand is binary language
or binary code which is made up of 0 (zero) and 1 (one). But writing
instructions in 0s and 1s is very difficult. That is why over a period
of time, computer science engineers and mathematics developed
languages closely related to English Language to write instructions
for the computer. These languages are called programming
languages.

A programming language is a language developed for writing


programs for a computer in a well defined way and with a set of
rules, which can be converted to binary codes and executed by
computer.
A computer program is a set of instructions arranged in a step by
step process based on some algorithm to perform a specific task.
In other words, a computer program is simply a collection of order
statements given to computer to give instructions for doing a
particular task. A computer program is written by a programmer in
a programming language, which is converted to machine language
by a compiler of interpreter. The machine language is nothing but
binary codes (0s and 1s) which is directly executed by a computer.
An algorithm is a well defined procedure or formula for solving a
problem, based on a sequence of specified actions.
An algorithm is a conceptual design of a computer program, which
can be implemented by using any programming language such as C,
C++, Java or PHP.
Algorithm listing steps to prepare tea:
1. Take water in a saucepan
2. Put it on gas stove
3. Add tea leaves to the saucepan
4. Add milk
5. Let it boil for a while
6. Add sugar
7. Strain into cups
Given above are the basic steps involved in preparing tea. In a
similar manner, we write an algorithm by breaking down a task
into simple steps. This algorithm is then converted into a
program in any of the programming languages.

BASIC BUILDING BLOCKS


a program is basically a set of instructions with two basic aspects.
The very first is the instruction statement and the second is
flow control. These are the basic building blocks of a program.
The Instruction Statement
A program consists of a set of instructions and each instruction is
defined in a statement. A statement is similar to a sentence in
English language. A program statement instructs the computer to
do something. This may be as simple as adding two numbers or as
complex as connecting a distant server over the internet.
Different types of statements include:
 Input statement
 Output Statement
 Assignment statement
 Expression Statement
 Compound statement
 Selection Statement
 Iteration statement
 Flow Control Statement or Jump Statement
For Example:

System.Out.Println(“Hello, World !”);


It is an output statement and would the following output on the
screen:

Hello, World !

Flow Control
This is very interesting part of learning a program. Flow of
control is the main concept of the program which enables one to
write a program in such a way that different conditions can lead
to different outputs.
To understand this concept, let me take you to a little bike ride.
Suppose you are on a bike, going to school. There can be more
than one path to reach your school and depending on each turn or
four ways you have to take a decision of going straight, left or
right. Depending on the number of four ways and turns between
your home and your school there can be many possible paths. In a
similar manner, there can be many different algorithms for a
particular problem depending on how you manage the execution
control of your program.
In this example, you are the control head, who is going through a
path to reach a particular destination. In an algorithm or
program, there is also a control head that goes through each line
of program and the path of that control head depends on what
you have written in the statements.
An Example
 Let x = 4
 If x is greater than 5
 Say “you are allowed in the group”.
 Else say “you are not allowed in the group”.
In this example of the algorithm, the control head will go through
first and second line then it will skip the third line and directly go
to fourth line. If the value of x were greater than 5 than control
head will run through on first three line of code and will never go
to fourth line. This is how the flow of control is managed.
PROGRAMMING PARADIGMS
Programming languages can be classified on the basis of their
features. This classification is referred to as a programming
paradigm.
A programming paradigm is style or way of programming.
All computer programs consist of two elements: code and data. A
program can be conceptually organized into ways, around its
code or around its data there are basically two programming
paradigms
 Procedure oriented programming (POP)
 Object oriented programming (OOP)
The first programming is called procedure oriented model.
Procedural languages such as BASIC employ this model. The
second approach is called object oriented model. It organizes the
program around its data (i.e. objects) and a set of interfaces to
that data.
Procedure Oriented Programming
The focus is on procedure or function as seen in the example
given below:
An Example
If we are developing a calculator program there can be a function
foe addition of two numbers. This add function can take two
numbers, make a sum of them and then can be returned. Similarly
we will create all the functions for each operation of the
calculator then combining them with another master program
will create a calculator.
 The program is written in a well defined step by step
procedure in top down approach.
 It defines a systematic order of statements and tracking down
the position of control head during execution is very easy.
 A problem is broken into small functions are routines for
solving a very specific part of a big problem. This function then
can be implemented with a small set of statement in an
ordered way.
 A popular procedural programming language is C languages.
Other examples include COBOL, FORTRAN, ALGOL and BASIC.

You might also like