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

Introduction To Programming Wk1

The document provides an introduction to programming concepts. It explains what a program is, the components of a computer system including hardware and software, and the steps involved in designing and writing programs such as using pseudocode and flowcharts. It also provides examples to illustrate these concepts.

Uploaded by

mysterymandel
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)
10 views

Introduction To Programming Wk1

The document provides an introduction to programming concepts. It explains what a program is, the components of a computer system including hardware and software, and the steps involved in designing and writing programs such as using pseudocode and flowcharts. It also provides examples to illustrate these concepts.

Uploaded by

mysterymandel
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/ 19

INTRODUCTION TO

PROGRAMMING

LECTURE 1
Learning Objectives

At the end of this lesson, students will be able to:


• Explain what is a program
• List and explain the various components of a computer
system
• List the steps involved in designing and writing programs
• Use pseudocode and flowchart in their program design
What is a program?
If you go to an ATM machine to withdraw money from your bank
account, you will come face to face with a screen which gives you
instructions for you to follow. Examples of the instruction could be as
follows:
• Please insert your bank card
• Please enter your pin number
• Please choose the service you want (eg. Withdrawal, fund
transfer, exit, etc)
• Please enter the amount you want to withdraw
• Please remove your card
• Please remove money from the slot Please take receipt
• Thank you and have a nice day
What is a program?
The instructions that tell the computer what to do are called software, or
programs, and are written by programmers.

Programs generally fall into one of two categories:


System software is the set of programs that control or enhance the
operation of a computer. Example. Operating System (Windows, iOS,
Mac OS, Linux)

Application software makes a computer useful for everyday tasks


(Microsoft offices, Game program, email programs, Web browser, Payroll
system).
Computer systems

A computer system is made up of a hardware and a software components.

The physical machine that you see is the hardware of the computer system.

This physical machine needs a "brain" to make it work, and that is the

software component. Let us take a closer look at these two components.

• Hardware

A computer system basically has 5 components: input device, output device,

the processor (or better known as CPU), main memory (better known as

RAM), and secondary memory.

An input device is to allow a person to communicate information to the

computer. In can be a keyboard, a mouse, a touch screen or any other device

that allows a person to enter an input or response to the computer.


Components of Computer systems

An output device allows the computer to communicate information to the


human, such as displaying information on a display monitor, printing out
information on a printer, producing information as a sound from a speaker,
etc.

The computer's processor and the main memory form the heart of
the computer and are usually thought of a one integrated unit.

The secondary storage is used to store a permanent сору of the


information. А hагd disk is the most common type of sесоndaгу memory you
will see. Other secondary memory are tapes, disks (CD or DVD), thumb
drives, etc.
Components of Computer systems

Software

Software is the program that allows you to "talk" to the computer. First of
all, the computer must have a program which is called the operating system.
The operating system is a special program which was written by experts
and its main purpose is to allow the machine to interact with you. The
operating system controls the computer’s resourсеs. If you want to run a
program, you will tell the operating system the name of the file that contains it,
and the operating system will run the program. This program which you
want to run is called an application program. Application programs can be
programs which you buy, or it can be programs which you write yourself.
Computer systems

A program is a set of instructions for a computer to follow. It can


be a simple set of instructions, or a complex one. In this course you
will learn how to design and write programs. Programs can be
written using computer languages. In this course we will use the C++
language to practice our program writing.
Programming

Programming is the process of creating instructions for computers to perform


specific tasks or solve problems. It involves writing, testing, and maintaining the
source code of computer programs. Programming languages are used to write
these instructions, and they allow developers to communicate with computers in a
way that they can understand.

Programming is essential in today's digital world, as it powers everything from


mobile apps and websites to complex software systems and artificial intelligence.
It requires logical thinking, problem-solving skills, and attention to detail.

There are many different programming languages, each with its own syntax and
purpose. Some popular programming languages include Python, Java, C++,
JavaScript, and so on. Each language has its strengths and weaknesses, making
them suitable for different types of projects.

Overall, programming is a valuable skill that can open up a wide range of career
opportunities in technology and beyond.
How To Design And Write Programs

If you want to write a program, you must first design it. But before you
can do any designing yon must first know what it is that you want and
what you want to achieve. All these are part of a process called the
software development life cycle (SDLC).

Software Development Life Cycle


When you decide to write a program, it is to solve a problem faced by
a user or to perform a certain task as required by a user. Writing a
program in real life will in many cases involve large, complex and
usable software. The software has a life cycle. There are six steps in
the software development life cycle and they are as follows:

1. Analysis (define the problem)


2. Design the software (algorithm design)
3. Implementation(writing the program code using a specific language)
4. Testing(test the program)
5. Maintenance
6. Obsolescence
Algorithm
An algorithm, which is a set of well-defined logical steps that must be taken to
perform a task.

You want to write a program that will help user convert US dollar into Leones.
You already determined the output of the program. The output will be to display
the amount in Leones on the computer screen. The input of the program is the
amount of US dollar, keyed in by the user from the keyboard. There is also a
second input, which is the conversion rate. Now you have to figure out the
process that will transform the value of the US dollars into an equivalent
value in Leones. In this example, the process in not very complex. To convert
the value, the computer has to multiply the value of the US dollars by the
conversion rate. We can put these information in an Input-Process-Output
(IPO)table as shown below:

Input Process Output

Value of USD Algorithm: Value in RM


Conversion rate 1. User enter the value of US dollars
(USD)
2. Enter the conversion rate
3. Calculate the value in Leones (Le) by
multiplying the value of USD by the
conversion rate
4. Display the value in Le
Pseudocode
A pseudocode is an artificial and informal language, which is similar to
everyday English, but is also allows you to use some kind of coding statements
similar to program language codes. There are no specific standards for
pseudocodes; each person may have his or her own style of writing pseudocode.
If a programmer is familiar with C++ language, he or she may feel comfortable to
use codes similar to C++, codes which are not actually C++ code. But why use
codes similar to C++ codes, why not just use actual C++ codes? In pseudocode,
he can use a mixture of C++ like codes and English. By doing this, he is able to
write the algorithm without having to worry about the details of C++ syntax (rules
of writing C++ codes). Below is how the pseudocode for Example 1 may be
written.

Start
Display “Enter value of US dollars (USD)”
Input USD
Display “Enter the conversion rate”
Input conversionRate
Set Leones =USD x conversionRate
Display “Le “ + Leones
End Program
Flowchart

Unlike pseudocode, flowcharts use a set of standardized symbols. There are


specific symbols for input and output; symbol for processes, symbols for start
and stop of program, symbol for decision and symbol to represent the flow of
the steps. There are other symbols for other purposes, but the ones that are
most common are summarized in the following diagram.

Oval - To start or terminate program /module

Parallelogram - For input /output data eg. Read data, display data, print data

Rectangle - For process, eg. Calculation, such as RM =USD x rate

Diamond - For decision (we will discuss this in later chapters

Arrow - For showing flow of proces:


Another Example

Write a pseudocode program that should calculate the number of km a car


can be driven per litre.

Algorithm

Input Process Output


Km per litre
Value of USD Algorithm:
Conversion rate 1. User enter the value of Km driven
2. Enter the litre of petrol
3. Calculate the value Km per litre by
dividing
the Km driven by the litre of petrol
4. Display the value of Km per litre
Pseudocode

Start
Display “Enter value of Km driven”
Input kmDriven
Display “Enter the litre of petrol used”
Input litre_of_petrol
Set km_per_litre = kmDriven / litre_of_petrol
Display km_per_litre
End Program
Exercises
• Sales Prediction
A company has determined that its annual profit is typically 23 percent of total
sales. Design a program that asks the user to enter the projected amount of
total sales, and then displays the profit that will be made from that amount.
Hint: Use the value 0.23 to represent 23 percent.

• Miles-per-Gallon
A car’s miles-per-gallon (MPG) can be calculated with the following formula:
MPG = Miles driven / Gallons of gas used
Design a program that asks the user for the number of miles driven and the
gallons of gas used. It should calculate the car’s miles-per-gallon and display
the result on the screen.

• Amount Paid Over Time


A person pays a fixed amount each month as a car payment. Design a
program that asks the user to enter the amount paid each month, and the
number of months the user has been making payments. The program should
then display the total amount that the user has paid.

You might also like