COMPUTER PROGRAMMING
LECTURE 1
PRESENTED BY:
Dr. Md Abdur Rahim
Associate Professor & Chairman
Department of Computer Science and Engineering
&
Director, ICT Cell
Pabna University of Science and Technology, Rajapur, Pabna.
Email: rahim@[Link]
Contact: +8801728548300
COMPUTER
A computer is an electronic machine that takes input from the user, processes
the given input and generates output in the form of useful information.
Requirements of a computer:
Process data
Store data
Move data between the computer and
the outside world
Control the operation of the above
COMPUTER (CONT.)
• Input: data, programs, user reply
• Data: the raw details that need to be processed to generate some useful information.
• Programs: the set of instructions that can be executed by the computer in sequential
or non-sequential manner.
• User reply: the input provided by the user in response to a question asked by the
computer.
COMPONENT OF A COMPUTER
• Input Unit
• Central Processing Unit(CPU)
• Output Unit
CPU is known as the brain of the computer system. All the operations within the
system are supervised & controlled by the CPU.
The CPU control all internal & external devices, perform arithmetic and logical
operation, controls memory usage, and control the sequence of operation.
PROGRAMMING
• Programming refers to a technological
process for telling a computer which tasks
to perform in order to solve problems
• Programming as a collaboration between
humans and computers, in which humans
create instructions for a computer to follow
(code) in a language computers can
understand.
PROGRAMMING (CONT.)
5 Types of Programming Languages
1. Procedural programming languages
A procedural language follows a sequence of statements or commands in order to
achieve a desired output.
• C and C++
• Java
• Pascal
• BASIC
PROGRAMMING (CONT.)
2. Functional programming languages
Rather than focusing on the execution of statements, functional languages
focus on the output of mathematical functions and evaluations.
• Scala
• Erlang
• Haskell
• Elixir
• F#
PROGRAMMING (CONT.)
3. Object-oriented programming languages (OOP)
This type of language treats a program as a group of objects composed of data and
program elements, known as attributes and methods.
• Java
• Python
• PHP
• C++
• Ruby
PROGRAMMING (CONT.)
4. Scripting languages
Programmers use scripting languages to automate repetitive tasks, manage dynamic web
content, or support processes in larger applications.
• PHP
• Ruby
• Python
• bash
• Perl
• [Link]
PROGRAMMING (CONT.)
5. Logic programming languages
Instead of telling a computer what to do, a logic programming language expresses a
series of facts and rules to instruct the computer on how to make decisions.
PHP
• Prolog
• Absys
• Datalog
• Alma-0
COMPUTER PROGRAMMING
• Computer programming is the process of writing code to facilitate specific actions
in a computer, application or software program, and instructs them on how to
perform.
• Computer programmers are professionals that create instructions for a computer
to execute by writing and testing code that enables applications and software
programs to operate successfully.
Programming Challenges
Is not just for experts Need to learn what computers can do
Is a natural, satisfying and creative experience Need to learn a programming language
Enables accomplishments not otherwise possible
The path to a new world of intellectual endeavor
COMPUTER PROGRAM
• Computer program – A set of logical instructions given to a computer for data
processing that is interpreted by a computer to produce useful information.
• It is therefore a must for computer programmers to learn the language the computer
can understand.
• Computer Language is composed of arithmetic operators, logical operators, relational
operators, important terminologies and systems
COMPUTER PROGRAM (CONT.)
PROBLEM ANALYSIS
• Problem analysis is a way of understanding the context within which you intend to
work.
• it provides a structured approach for identifying problems and their root causes to
ensure that attention is focused upon the real issues.
Five Steps for problem analysis: Identify, analyze, resolve, execute, evaluate
• Step 1: Identify: Identifying the problem may be simple, or it could be a detailed
cognitive process that breaks the issue into manageable components.
• Step 2: Analyze: Consider underlying factors and devise strategies.
• Step 3: Resolve: Develop some reasonable solutions that are aligned with the
capabilities of your team and the mission, vision, and values of your company.
• Step 4: Execute: The execution phase is the bridge between theory and
practice
• Step 5: Evaluate: reflect on the outcome of your problem solving strategies
PROBLEM SOLVING
ALGORITHM
• An algorithm is a procedure used for solving a problem or performing a computation.
• Algorithms act as an exact list of instructions that conduct specified actions step by step in
either hardware- or software-based routines.
ALGORITHM (CONT.)
Use of the Algorithms
Computer Science
Mathematics
Operations Research
Artificial Intelligence
Data Science
How to Design an Algorithm?
1. The problem that is to be solved by this algorithm i.e. clear problem definition.
2. The constraints of the problem must be considered while solving the problem.
3. The input to be taken to solve the problem.
4. The output is to be expected when the problem is solved.
5. The solution to this problem is within the given constraints.
ALGORITHM (CONT.)
Example: Consider the example to add three numbers and print the sum.
Algorithm to add 3 numbers and print their sum:
1. START
2. Declare 3 integer variables num1, num2, and num3.
3. Take the three numbers, to be added, as inputs in variables num1, num2, and
num3 respectively.
4. Declare an integer variable sum to store the resultant sum of the 3 numbers.
5. Add the 3 numbers and store the result in the variable sum.
6. Print the value of the variable sum
7. END
Advantages of Algorithms: Disadvantages of Algorithms:
• It is easy to understand. • Writing an algorithm takes a long time so it is time-
• An algorithm is a step-wise representation of a consuming.
solution to a given problem. • Understanding complex logic through algorithms can
• In an Algorithm the problem is broken down into be very difficult.
smaller pieces or steps hence, it is easier for the • Branching and Looping statements are difficult to show
programmer to convert it into an actual program. in Algorithms.