[go: up one dir, main page]

0% found this document useful (0 votes)
143 views12 pages

Csc201: Introduction To Computer Programming I What Is A Computer?

This document provides an overview of computer programming and programming languages. It discusses: 1) What a computer is and its basic functions of input, storage, processing, and output. 2) The five generations of computers from vacuum tubes to modern microprocessors. 3) The differences between system software, application software, and programming languages. 4) The three levels of programming languages from machine language to high-level languages.

Uploaded by

Tomisin Eniola
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)
143 views12 pages

Csc201: Introduction To Computer Programming I What Is A Computer?

This document provides an overview of computer programming and programming languages. It discusses: 1) What a computer is and its basic functions of input, storage, processing, and output. 2) The five generations of computers from vacuum tubes to modern microprocessors. 3) The differences between system software, application software, and programming languages. 4) The three levels of programming languages from machine language to high-level languages.

Uploaded by

Tomisin Eniola
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/ 12

CSC201: INTRODUCTION TO COMPUTER PROGRAMMING I

What is a Computer?
A computer is basically defined as a tool or machine used for processing data to give required
information. It is capable of:
a. taking input data through the keyboard (input unit)
b. storing the input data in a diskette, hard disk or other medium
c. processing it at the central processing unit (CPU) and
d. giving out the result (output) on the screen or the Visual Display Unit (VDU).

GENERATIONS OF ELECTRONIC DIGITAL COMPUTER


(i.) 1st Generation

• 1946-1959.
• Started with using vacuum tubes
• Tubes like electric bulbs produced a lot of heat
• very expensive , could be afforded only by very large organizations,
• expensive to power,
• huge size,
• supported machine language only, not portable,
• often unreliable, slow, limited internal storage, and punched cards were used to enter data
• batch processing operating systems were used.
• Examples of computer of this generation were: ENIAC, EDVAC, UNIVAC, IBM-701,
IBM-650, etc.

(ii.) 2nd Generation


• 1959-1965.
• The use of transistors
• Cheaper, and consumed less power,
• more compact in size, more reliable and faster
• Example of computer: IBM 7070, IBM 1620, IBM 7094, CDC 1604,
CDC 3600, UNIVAC 1800, and etc.
(iii.) rd
3 Generation
• 1965-1971.
• use of Integrated Circuits (IC's)
• smaller in size, reliable and efficient.
• generate less heat, faster, lesser maintenance, still costly,
• consumed lesser electricity and support high-level language.
• Examples: IBM-360 series, Honeywell-6000 series, PDP(Personal Data Processor),
IBM-370/168 and TDC-316.
• Time sharing, Real time, Networks, Distributed Operating System were used.
higher level languages C and C++, DBASE, etc.

(iv.) 4th Generation

1
• 1971-1980.
• Use of VLSI circuits
• More powerful, and compact, reliable, and affordable. As a result, it gave rise to personal
computer (PC) revolution.
• Examples: DEC 10, STAR 1000, PDP 11,
• CRAY-1 (Super Computer), CRAY-X-MP (Super Computer), etc.
(v.) th
5 Generation
• 1980-till date.
• production of microprocessor chips
• more user friendly interfaces with multimedia features,
• availability of very powerful and compact computers at cheaper rates.
• Some computers types of this generation are: Desktop, Laptop, NoteBook, UltraBook, and
ChromeBook.

Hardware & Software – physical and tangible components of computer/ non- physical
(i.) System Software
• Collection of programs design to operate and control computer
• Designed in machine languages
Examples
• Operating System
• Compilers
• Interpreters
• Assemblers

(ii.) Application Software

• Designed to satisfy a particular needs


• They are single program or a collection called suite e.g. Microsoft Office
Examples
• Payroll Software
• Student Record
• Inventory Management Software
• Income Tax Software

What is Programming
A computer program is a series of instructions given to the computer at a particular time to solve a
problem. It is a set of codes that instructs the computer to carry out some processes. It is usually written
in a particular programming language, and named according to the language used in writing it.

Why program a computer?


Basically, human beings cannot speak or write in computer language, and since computers cannot speak
or write in human language, an intermediate language had to be devised to allow people to communicate
with the computers. These intermediate languages, known as programming languages, allow a computer
programmer to direct the activities of the computer. These languages are structured around unique set
of rules that dictate exactly how a programmer should direct the computer to perform a specific task.
2
With the powers of reasoning and logic of human beings, there is the capability to accept an instruction
and understand it in many different forms. Since a computer must be programmed to respond to specific
instructions, instructions cannot be given in just any form. Programming languages standardize the
instruction process.

Programming Languages
Programming languages are languages through which we can instruct the computer to carry out some
processes or tasks. It is the language through which we can pass instructions to user and the system.
They are also designed to communicate ideas about algorithms between human beings and computers.
Programming languages can be used to execute a wide range of algorithms, that is, an instruction could
be executed through more than a procedure of execution.
Programming is the process of writing programs.

Levels of Programming Languages


Programs and programming languages have been in existence since the
invention of computers, and there are three levels of programming languages. These are:
i. Machine Language
ii. Symbolic Language/low level language/assembly language
iii. High Level Language

Machine Language:
Machine language is a set binary coded instruction, which consists of zeros
(0) and ones (1). Machine language is peculiar to each type of computer. The first generation of
computers was coded in machine language that was specific to each model of computer.
Some of the shortcomings of the machine language were:
1. Coding in machine language was a very tedious and boring job
2. Machine language was not user-friendly. That is the user had to remember a long list of codes,
numbers or operation codes and know where instructions were stored in computer memory.
3. Debugging any set of codes is a very difficult task since it requires going through the program
instruction from the beginning to the end.
The major advantage of machine language is that it requires no translation since it is already in machine
language and is therefore faster to execute.

Low Level Language:


This is a level of programming language which is different from the machine language. That is, the
instructions are not entirely in binary coded form. It also consists of some symbolic codes, which are
easier to remember than machine codes.
In assembly language, memory addresses are referenced by symbols rather than addresses in machine
language. Low level programming language is also called assembly language or symbolic language,
because it makes use of an assembler to translate codes into machine language.
An example of assembly language statement is:

MOVE A1, A2 → Move the contents of Register A2 to A1


JMP b →Go to the process with label b

The disadvantages of assembly language are that:


3
- It is specific to particular machines
- It requires a translator called an assembler.

The major advantage of the assembly language is that programs written in it are easier to read and more
user friendly than those written in machine language, especially when comments are inserted in the
codes.

High Level Language:


The difficulty of programming and the time required to program computers in assembly languages and
machine languages led to the development of high-level languages. This programming language consists
of English-like codes. High-level language is independent of the computer because the programmer only
needs to pay attention to the steps or procedures involved in solving the problem for which the program
is to be used to execute the problem.
Some advantages of high-level language:
 Machine and assembly language programming is machine dependent but high level languages
are machine independent, that is, a high-level language program can be run on a variety of
computer.
 The flexibility of high level languages is greater than that of the machine and assembly languages
 It is more user friendly, that is, easy to learn and write
 It is very portable, that is, it can be used on almost any computer
 It saves much time and effort when used compared to any other programming level language.
 Codes written in this language can easily be debugged.

Examples are FORTRAN, COBOL, PASCAL, C, etc.

i. BASIC - Beginners All Purpose Symbolic Instruction Code


ii. COBOL - Common Business Oriented Language
iii. FORTRAN - Formula Translation
iv. PASCAL - Named after French mathematician Blaise Pascal
v. JAVA
vi. Python

Features of Programming Languages


There are some conventional features which a programming language must possess, these features are:
 It must have syntactic rules for forming statements.
 It must have a vocabulary that consists of letters of the alphabet.
 It must have a language structure, which consists of keywords, expressions and statements.
 It may require a translator before it can be understood by a computer.
 Programming languages are written and processed by the computer for the purpose of
communicating data between the human being and the computer.

Stages of Programming
The preparation of a computer program involves a set of procedure. These steps can be classified into
eight major stages, viz
(i) Problem Definition

4
(ii) Devising the method of solution
(iii) Developing the method using suitable aids, e.g. pseudo code or flowchart.
(iv) Writing the instructions in a programming language
(v) Transcribing the instructions into “machine sensible” form
(vi) Debugging the program
(vii) Testing the program
(viii) Documenting all the work involved in producing the program.
1. Problem definition
The first stage requires a good understand of the problem. The programmer (i.e. the
person writing the program) needs to thoroughly understand what is required of a
problem. A complete and precise unambiguous statement of the problem to be
solved must be stated. This will entail the detailed specification which lays down the input,
processes and output-required.
2. Devising the method of solution
The second stage involved is spelling out the detailed algorithm. The use of a
computer to solve problems (be it scientific or business data processing problems)
requires that a procedure or an algorithm be developed for the computer to follow in solving the
problem.
3. Developing the method of solution
There are several methods for representing or developing methods used in solving a problem.
Examples of such methods are: algorithms, flowcharts, pseudo code, and decision tables.
4. Writing the instructions in a programming language
After outlining the method of solving the problem, a proper understanding of the syntax of the
programming language to be used is necessary in order to write the series of instructions required
to get the problem solved.
5. Transcribing the instructions into machine sensible form
After the program is coded, it is converted into machine sensible form or machine language. There
are some manufacturers written programs that translate users program (source program) into
machine language (object code). These are called translators and instructions that machines can
execute at a go, while interpreters accept a program and executes it line-by-line.
During translation, the translator carries out syntax check on the source program to detect errors
that may arise from wrong use of the programming language.
6. Program debugging
A program seldomly executes successfully the first time. It normally contains a few errors (bugs).
General violations of the rule of programming or pitfalls of computer arithmetic are referred to as
Errors or Program Errors Debugging is the process of locating and correcting errors. During
program execution, errors detected will be listed, corrected by the programmer and program re-
run carried out again. After corrections have been made, the program is again read into the
computer and again processed by the language translator. This is repeated over and over again
until the program is error-free. There are three classes of errors.
(i.) Syntax errors: Caused by mistake coding (illegal use of a feature of the programming
language). Errors due to misspelled (spelling errors) statements or instructions or wrong
use or non use of punctuation marks (such as commas, colon etc.) where necessary. When
such errors are detected, the programmer should look at the program for possible spelling
errors or omission of punctuation marks.

5
(ii.) Logic errors: Caused by faulty logic in the design of the program. The program will work
but not as intended.
(iii.) Execution errors: The program works as intended but illegal input or other
circumstances at run-time makes the program stop. E.g.
– Conversion Error: numbers are mostly stored in their binary form. A decimal number 0.5
is represented by the binary number 0.1 in such computers. Again, a number 1/10 is
represented by 0.0001100110011……. which has no finite binary representation. Depending
on the computer word length, errors will be noticed if the arithmetic operations become
bigger.
– Round-off Error: this occurs when a specific significant digits are used, for example, 1/3
which supposed to be 0.3333333….. could be stored as 0.333.
– Run-time Error: this error occurs when the translator come across wrong mathematical
operation during program execution. This could occur, as an example, when a number is
divided by zero.

7. Program testing
The purpose of testing is to determine whether a program consistently produces correct or expected
results. A program is normally tested by executing it with a given set of input data (called test
data), for which correct results are known.
8. Program documentation:
Documentation of the program should be developed at every stage of the programming cycle. The
following are documentations that should be done for each program.

(a) Problem Definition Step


• A clear statement of the problem
• The objectives of the program (what the program is to accomplish)
• Source of request for the program.
• Person/official authorizing the request.
(b) Planning the Solution Step
• Flowchart, pseudocode or decision tables
• Program narrative
• Descriptive of input, and file formats
(c) Program source coding sheet
(d) User’s manual to aid persons who are not familiar with the program to apply it correctly. It
contains a description of the program and what it is designed to achieve.
(e) Operator’s manual to assist the computer operator to successfully run the program. This manual
contains:
 Instructions about starting, running and terminating the program.
 Message that may be printed on the console or VDU (terminal) and their meanings.
 Setup and take down instruction for files.

Advantages of Program documentation


(i.) It provides all necessary information for anyone who comes in contact with the program.
(ii.) It helps the supervisor in determining the program’s purpose, how long the program will be
useful and future revision that may be necessary.
(iii.) It simplifies program maintenance (revision or updating)

6
(iv.) It provides information as to the use of the program to those unfamiliar with it.
(v.) It provides operating instructions to the computer operator.

Properties of a Good Program


Program developments are accomplished by giving the computer sequence of statements to perform and
solve specific tasks. A good programming practice is needed to write a good program. Program
development has to follow problem definition, analysis, modelling, algorithm/flowchart design, coding
and documentation. The following properties are required for developing a good program.

i. Program Correctness: a good program must be able to solve the intended problem with relevant
results. The output (result) must be readily available for testing with assumed or calculated
results using real or dummy data.
ii. Documentation: every module or procedure must be preceded with comments on brief
explanation of the module in the program. These make programs easy to read and understand by
other users that may want to modify or improve on the program. Complete documentation of the
whole program is also necessary to give details of the input, output, processing tasks and manual
guide.
iii. Robustness and Scalability: programs that can survive various unexpected events are said to
be robust and those that can easily be upgraded are scalable. They are sometimes called safe or
defensive programs because of the way they are written, the choice of variable names, surviving
incorrect data etc.
iv. User Interface: a good look or design of the medium of interaction of the user and the program
must be well taken care so as to have a good user interface. This is the part of the program that
performs the dialog aspect of the program with the user and must be easy and friendly to use.
v. Program Style: the programming language rules are to be adapted in writing programs. You
should not do what is not to be done with the programming language in question.
vi. Use of Tools and Library Functions: programming languages have special tools and libraries
that can assist in developing computer programs. Some editors are also used to enhance the
development of programs.

Computer Program Design


Before you begin to write code, you need a clear understanding of the tasks the program must perform:
the requirements and the steps it should take to perform them. The steps a program must take to perform
a task is known as the program’s flow. You can design a program’s flow by using algorithms and
flowcharts.
An algorithm is a set of procedures for solving a problem. it is a finite sequence of unambiguous
instructions for solving a problem, i.e., for obtaining a required output for any legitimate
input in a finite amount of time. Since an algorithm is just the solution steps for a problem, it can be
represented by ordinary English expressions.

Characteristics of Algorithms
The following are the major considerations in the design of algorithms
• An algorithm must have a beginning and an end
• The non- ambiguity requirement for each step of an algorithm cannot be compromised.
• The range of inputs for which an algorithm works has to be specified carefully
• The same algorithm can be represented in several different ways
7
• Several algorithms for solving the same problem may exist
• Algorithms for the same problem can be based on very different ideas and can solve the problem
with dramatically different speeds
• It must terminate at a reasonable period of time.

An algorithm is a step-by-step description of a procedure. Writing an algorithm allows you to think


about the logic of a program without worrying about the syntax of the programming language.
You can think of an algorithm as being like a recipe:

1. Put 1 tablespoon of oil in a frying pan.


2. Heat the oil on the stove at low temperature.
3. Break three eggs into a bowl.
4. Beat the eggs with a whisk.
5. Add cheese.
6. Add seasonings.
7. Add the egg mixture to the frying pan.
8. Cook on both sides.

Example: Problem: Design an algorithm to find the average of two numbers.


Solution:
1. Start
2. Get the first number
3. Get the second number
4. Add the two numbers together
5. Show the result
6. Stop

An algorithm can be written by using pseudocode and flowcharts

Writing Algorithms Using Pseudocode


As the word suggests, pseudocode is like code but different. In fact, pseudocode is a description of the
program flow, written in the language you speak. When you write pseudocode, you usually keep the
sentences short and to the point.

Writing Algorithms Using Flowcharts


Flowcharts is to show graphical representation and step-by-step method of solving problems. Flowchart
has been used to show visual pictures that give the steps in the algorithm and also the flow of control
between the various steps in the algorithm
As programs become more complex, a flowchart is most helpful in planning, designing, and structuring
a program. A flowchart is a graphical representation of an algorithm.
A flowchart is a graphical representation of a program’s logic. You can draw a flowchart on paper or
using a flowcharting tool such as Microsoft Visio. There are even flowcharting objects available in
Microsoft Office.

8
When you draw a flowchart, you should use industry-standard shapes to represent each step in the
process. You usually draw the flow from top to bottom or from left to right. Arrows connect the shapes
to define the flow.

Flowchart Symbols
Flowcharts are drawn with the help of symbols. The following are the most commonly used flowchart
symbols and their functions:

9
10
Case

Example 1: Finding the sum of two numbers.


11
– Algorithm:
Step 1 – Start
Step 2 – Input A
Step 3 – Input B
Step 4 –Calculate C = A + B
Step 5 – Output C
Step 6 – Stop

Example 2: Find the difference and the division of two numbers and display the results.

Algorithm:
Step 1: Start
Step 2: Input N1
Step 3: Input N2
Step 4: D = N1 –N2
Step 5: V = N1 / N2
Step 6: Output D
Step 7: Output V
Step 8: Stop

12

You might also like