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

BM Lagi

This document provides an introduction to computer programming concepts including: - Computers process data according to programs called instructions. - Computers have hardware components like keyboards and processors and software programs. - An example problem of calculating employee salaries is used to demonstrate computer inputs, processes, outputs, and storage. - Programming involves planning step-by-step instructions for computers using a programming language. - Common programming languages include machine language, assembly language, and high-level languages. - Well-designed programs are correct, understandable, maintainable, efficient, reliable, and flexible. - The programming process involves specification, analysis, design, testing, implementation, and documentation. - Algorithms and pseudocode

Uploaded by

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

BM Lagi

This document provides an introduction to computer programming concepts including: - Computers process data according to programs called instructions. - Computers have hardware components like keyboards and processors and software programs. - An example problem of calculating employee salaries is used to demonstrate computer inputs, processes, outputs, and storage. - Programming involves planning step-by-step instructions for computers using a programming language. - Common programming languages include machine language, assembly language, and high-level languages. - Well-designed programs are correct, understandable, maintainable, efficient, reliable, and flexible. - The programming process involves specification, analysis, design, testing, implementation, and documentation. - Algorithms and pseudocode

Uploaded by

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

EKT120 Introduction to

Computer Programming
Week1-Introduction to Computer and
Computer Program
A Brief Look At Computer
Computer
is a device that receives input, stores and processes data,
and provides output in a useful format.
Computers process data according to sets of instructions
called computer programs
Example: laptops, PCs, mainframes, even everyday objects
such as mobile phones, washing-machines, TV sets, cars
contain computers
Hardware
Physical components of a computer
Example: Keyboard, screen, mouse, disks, memory, CD-
ROM, and processing units
Software
Programs that run on a computer
Example: Operating System such as windows XP -Vista -7,
Word processing packages such as MS Word, registration
program
Computer Hardware
Exercise:
Distinguishing between
input-process-output-storage
The scenario: At the end of each month, a clerk enters the employee
name, number of days present and absent, and the number of overtime
done in the system. The system then calculates the normal salary, the
amount for overtime and the total salary. The clerk then saves the
information in the computer hard disk, and takes a backup on a cd. A
report is produced for the clerk so that the latter can show to the manager.
Task: Identify the following for that particular system
Input: the employee name, number of days present and absent, the number
of overtime
Process(es): calculate normal income, calculate amount for overtime,
calculate total salary
Output: Report
Storage: Harddisk, CD-ROM
How Computer Processes
Information
Computers are NOT intelligent
Computers do what we tell them to do they don’t do anything by
themselves.
We must clearly tell a computer what to do in a step by step
manner using a programming language.
Computers only understand “electronic”
High voltage/low voltage – The machine language
Machine language is binary (two values: high/low) 1’s and 0’s
Why we use computer
Computers produce fast, accurate and reliable results.
While computers do the boring, repetitive, ordinary
tasks, we can spend our efforts and time to work on more
interesting and creative tasks.
The use of computers in business and manufacturing
decreases the cost of goods and services produced.
It is more difficult and needs more time to find or grow
up a skill-full labour in IT industry, while buying an
additional computer and installing the required software
on is easier and cheaper.
Programming / Program /
Programmer
Programming in general term is planning or implementation
of a task or event command. In the computing field, is
instructing a computer to perform specific tasks.
Computer programming can be defined as the process of
planning a set of sequence commands to be executed by a
computer.
Program be defined as a set of sequence commands that
have been determined to be executed by a computer.
Computers are just electronic devices that have the power to
perform difficult tasks but they do not ‘KNOW’ what to do
therefore - programmers tell the computers what to do by
writing programs
Types of Programming languages
Machine language
Strings of numbers giving machine specific instructions
Example: +1300042774, +1400593419,
+1200274027
Assembly language
English-like abbreviations representing elementary
computer operations (translated via assemblers)
Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
High level language
Codes similar to everyday English. Use mathematical
notations (translated via compilers) Example Code:
grossPay = basePay + overTimePay
Example high level languages: C, C++, Cobol, Java,
Pascal (Delphi), Basic (Visual Basic) Fortran, SQL, T-SQL,
C# …
Programming Problem
Problem that can be solved using programming
language.
Suppose you want to add 34 and 56, this is easy. But to
add 100 numbers is difficult for us need to use calculator
or paper and pencil. Or we can write a program for
computer to help us.
Can these problems solve by computer programming?
Converting units from kilograms to grams.
Counting the number of cars on a highway.
Finding a life partner
Total rain in a week
How long we live
What we want to eat for dinner
Use of programs to solve problems
Data, Information
and Knowledge
Data are the raw facts, gathered from the
environment which does not have much meaning.
Note: Data is plural, singular form is Datum.
Information is the end product of the processing of
data, which has more meaning, and is used in
decision making.
Knowledge is the proved and generalized form of
information, that is used in strategic planning.
Properties of Well Designed Programs

Well designed programs must be:


Correct and accurate
Easy to understand
Easy to maintain and update
Efficient -
Reliable – can be rely on
Flexible – easily adapt in other situation / problem

Easy to Easy to Flexible


Correct and maintain and Efficient Reliable
accurate understand
update
Steps involve in programming
(Planning)
Requirement Specification: Eliminate ambiguities, Clearly
understand the problem
Analyze the problem: Understand the inputs, outputs and
processes used for manipulating the data, formulas and constraints
Design: Write the algorithm (flowchart or pseudocode) to
represent the solution
Testing and verification: Check the algorithm.
Implement the algorithm: Write a program
Testing and Verification: Check the program
Documentation
Algorithm
An algorithm is the plan for writing a program.
Steps required for solving a problem are listed
by using an algorithm tool.
Algorithm tools make program solutions more
clear, more understandable, and easier to
remember.
Algorithms are written according to rules so that
other programmers are also able to read and
understand the solution easily.
Tools of Algorithm
There are many Algorithm tools in use, but the
most popular ones are Pseudo-Codes and
Flowcharts.
In this course for all problems we will use both of
these tools but in general you choose only one.
Pseudo-code
Pseudo-code is structured english that is used as an
alternative method to flowcharts for planning structured
programs.
There are no general accepted standards for
pseudocodes.
We will work with a form that has minimum number of
rules and is essentially language-independent.
Pseudo-code instructions are written in English, they
can be easily understood and reviewed by users.
The only syntax rules to be concerned with involve the
LOOP and SELECTION structures. They must be used
as CAPITALISED words.
start Pseudocode
Insert key
Insert key
Free the gear
Turn on to starting position
Free gear
IF (engine starts in 6 sec)
4.1 YES – go to step 5
Turn the key to starting position

no
4.2 NO – IF (> 5 times)
4.2.1 YES – call workshop go
Engine
no to step 5
starts in 6
seconds?
>5 times
4.2.2 NO – go to step 3
5. Release the key
yes yes 66. End
Release key to ignite position Call workshop

end
Flowchart
Flowcharts are graphical
tools, containing a set of
shapes, each expressing a
different action in a
sequence of program
execution.
There are many different
shapes that are used for
specific purposes, to avoid
complexity, in this course,
only a limited subset of
these shapes will be shown
and used in applications.
Example

no
yes

yes

no n
yes o

no yes
Example 1
Begin

Making a cup of tea Plug in kettle

Put teabag in
cup

In the pseudo code Put water into


kettle
BEGIN
Plug in kettle; Boil the water
Put teabag in cup;
Put water into kettle; no
Is water
Boil the water; boiling?

Wait for kettle to boil; yes

Add water to cup;


Add water into cup
Remove teabag with spoon/fork;
Add milk and/or sugar; Remove teabag
END
Add milk/sugar

End
Exercise 1
Write an algorithm that will ask user to input 10 students' marks and
calculate the average students' mark and display all ten marks and the
average students' mark:
Exercise 2
Write an algorithm that will ask user to input a number then your
design will calculate and display the square of ınput number:
Exercise 3
Write an algorithm that will ask user to input height in meters then
your design will convert and display the cm value of input number
Write an algorithm to input a student's mark and determine the
student's grade. Use table below to determine the grade

Marks Grade
>90 A
80 - 89 B
70 - 79 C
60 - 69 D
< 60 E
References
Yuksel Uckan, Problem Solving Using C,Structured
Programming Techniques, McGraw-Hill
Deitel and Deitel, C: How to Program, McGraw-Hill
Cheng, H., “C for Engineers and Scientists”, McGraw Hill,
2010.
Hanly, J.R. and Koffman, E.B., “C Program Design for
Engineers”, 2nd Ed., Addison-Wesley, 2001.
ISBN : 0321204174

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy