0% found this document useful (0 votes)
50 views24 pages

Introduction To Programming-SE1133

This document provides an introduction to programming concepts. It defines a computer as a device that can accept input, process it, and produce output. Programs are sequences of instructions that direct a computer to solve problems. Programming languages include machine code, assembly language, and high-level languages like Python and Java. The problem solving process involves understanding the problem, planning logic steps, coding the program, testing it, and deployment. Pseudocode and flowcharts can help plan logic before coding.

Uploaded by

Qadir Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views24 pages

Introduction To Programming-SE1133

This document provides an introduction to programming concepts. It defines a computer as a device that can accept input, process it, and produce output. Programs are sequences of instructions that direct a computer to solve problems. Programming languages include machine code, assembly language, and high-level languages like Python and Java. The problem solving process involves understanding the problem, planning logic steps, coding the program, testing it, and deployment. Pseudocode and flowcharts can help plan logic before coding.

Uploaded by

Qadir Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Introduction to Programming- SE1133

Lecture 3 – Intro to Programming

Asia Shahab
Previous Lecture Summary

• Introduction to Computers

• Components of a Computer

• Storage Devices

• Register Memory

• System Software

• Application Software
What is a Computer??

• A computer is an electronic device that manipulates information, or data. It has the ability
to store, retrieve, and process data.

• Computer is an electronic device that takes raw data as an input from the user and processes
it under the control of a set of instructions (called program), produces a result (output), and
saves it for future use.

• A computer is a machine or device that performs processes, calculations and operations based
on instructions provided by a software or hardware program. It has the ability to accept data
(input), process it, and then produce outputs.
Cont…
• Computers are electronic devices that can follow instructions to
• Accept input
• Process that input
• Produce information
• Alternatively, a computer is a device capable of performing calculations and making
logical decisions at speeds millions, and even billions, of times faster than human
beings can.

Instructions
A Computer Results
System
Data
Computer Instructions and Programs

Instruction:
A computer instruction is a command or directive/instruction given to a
computer to perform specific task.
Examples: Add 2 and 5, Print “Hello World”

Program:
A program is sequence of instructions written in programming language that
directs a computer to solve a problem
Examples: Draw a square, etc.
Cont…
Program “Draw a square”

1 – Draw a vertical line of length n inches


2 – Draw a horizontal line of n inches
3– Draw a vertical line of length n inches
4 – Draw a horizontal line of n inches
8
Computer Software System

Application Programs
(.cpp, .c, .java,)

Compilers / Libraries
(C++, C, Java)

Operating Systems
(Windows, Linux, MAC, Solaris)

Computer Hardware
9
Programming Languages

Classification of programming languages:

1. Machine language

2. Low-level languages

3. High-level languages

10
1. Machine level languages

A computer understands only sequence of bits or 1’s and 0’s

A computer program can be written using machine languages


(01001101010010010….)

• Very fast execution

• Very difficult to write and debug

• Machine specific (different codes on different machines)


11
2. Low level languages
• English encrypted words instead of codes (1’s and 0’s)

• Requires: “Translation”/Assembler from Assembly code to


Machine code

• More understandable (for humans) i.e. Assembly language

Assembly Code Machine Code


compare: 1001010101001101
cmpl #oxa,n 1110010110010100
Assembler
cgt 0101010111010010
end_of_loop 0110100110111011
acddl #0x1,n 1101100101010101
end_of_loop:
12
3. High level languages
• Mostly machine independent

• Close to natural language (English like language keywords)

• Easy to write and understand

• Easy to debug and maintain code

• Requires compilers to translate into machine code

• Examples: Java, C++, Python etc.


13
Problem Solving Steps

1. Understand the problem

2. Plan the logic

3. Code the program

4. Test the program

5. Deploy the program into production

14
1. Understanding the Problem
• Problems are often described in natural language like English.

• Users may not be able to specify needs well, or the needs may changing frequently

• Identify the requirements

1. Inputs or given data-items

2. Required output(s) or desired results

3. Indirect inputs (may not be given directly, you have to calculate or assume)

15
1. Understanding the Problem
Example: Calculate the area of a circle having the radius of 3 cm

• Inputs: Radius=3

• Output: Area

• Indirect Inputs: Pi=3.14

Area = pi r^2

3.14 * (3*3) = 28.27

16
2. Plan the Logic

• Identify/Outline small steps in sequence, to achieve the goal (or


desired results)

• Tools such as flowcharts and pseudocode can be used:

• Flowchart: a pictorial representation of the logic steps

• Pseudocode: English-like representation of the logic

• Walk through the logic before coding

17
3. Code the Program
Code the program:

• Select the programming language

• Write the program instructions in the selected programming language

• Use the compiler software to translate the program into machine


understandable code or executable file (i.e. .cpp)

• Syntax errors (Error in program instructions) are identified by the


compiler during compilation and can be corrected.

18
4. Test the Program
Testing the program
• Execute it with sample data and check the results
• Identify logic errors if any (undesired results or output) and correct
them
• Choose test data carefully to exercise all branches of the logic
(Important)

19
5. Deploy the Program

Putting the program into production


• Do this after testing is complete and all known errors
have been corrected

20
Introduction to Pseudocode
• One of the popular representation based on natural language/
English like statements
• Easy to read and write
• Allow the programmer to concentrate on the logic of the
problem
• Structured in English language (Syntax/grammar)
• Each instruction is written on a separate line
• Written from top to bottom, with only one entry and one
exit
Cont…

Example: Calculate the area of a circle having the radius of


3 cm

Pseudocode:

• Get radius of a circle

• Calculate Area

• Display Area
Flowcharts
• “A graphic representation of a sequence of operations to
represent a computer program”
• Flowcharts show the sequence of instructions in a single
program.
Flowchart Symbols
Name Symbol Description

Oval Beginning or End of the Program

Parallelogram  Input/Output Operations

Rectangle Processing for example, Addition,


Multiplication, Division, etc.

Denotes Decision (or branching)


Diamond
for example IF-Then-Else

Arrow Denotes Direction of logic flow


Flowchart
Example: Calculate the area of a • START
circle having the radius of 3 cm.
Input
Radius (r)

Calculate Area =
3.14 * r * r

Display
Area

END
Summary

• What Is Computer?

• Computer Instructions and Programs

• Programming Languages

• Problem Solving Steps

• Pseudocode

• Flowcharts

You might also like