Unit 1
Unit 1
UNIT 1
OBJECTIVES
INPUT
Before we start writing our own programs let us examine some important
characteristics of well-written computer programs. Basically these apply to
any programming language that provide a useful set of guidelines.
a. Integrity. This refer to the accuracy of the calculations since it will be
meaningless if calculations are not carried out correctly.
b. Clarity. This refer to the overall readability of the program, with
particular emphasis on its underlying logic. If a program is clearly
written, it should be possible for programmer to follow the program logic
with ease.
c. Simplicity. The clarity and accuracy of a program are usually enhanced
by keeping things as simple as possible, consistent with the overall
program objectives.
d. Efficiency. This is concerned with execution speed and efficient memory
utilization.
e. Modularity. Many programs can be broken down into a series of
identifiable subtask that enhances accuracy and clarity of a program and
facilitates future program alterations.
f. Generality. Usually we will want a program to be as general as possible,
within reasonable limits. A considerable amount of generality can be
obtained with very little additional programming effort.
E3062/1/3
Basic Concept And Problem Solving in Programming
1.2.1 Declaration
A declarations associates a group of variables with a specific data
type. All variables must be declared before they can appear in
excutable statements.
Example :
int a, b, c;
float root1, root2;
char flag, text[80]
1.2.2 Input
A set of information called data will be entered into the computer
from keyboard, floppy disk, hard disk etc. and stored in a portion of
the computer memory. This input which is an input to the computer
will then be processed to produced the desired result.
1.2.3 Storage
Every piece of information are stored within the computer’s memory
which is encoded as some unique combination of zeros and ones.
Small computers have memories that are organized into 8-bit
multiples called bytes. Large computer have memories that are
E3062/1/4
Basic Concept And Problem Solving in Programming
1.2.4 Operation
There are two different ways computer can be utilized by many
different users. These are batch mode and the interactive mode. In
batch mode of operation the program and the data are typed into the
computer and stored within computer’s memory and processed in its
proper sequence. Large quantities of information can be transmitted
into and out of the computer without the user present while the job
being processed. Batch processing can be undesirable for simple jobs.
In interactive mode the user and the computer are able to interact with
each other during computational session.
1.2.5 Control
Program control refers to the order of execution of instructions in a
program. The instruction can be executed sequentially – one by one,
from top downwards or non sequential execution of program
instruction. Most real life problems require some kind of decision
making to take a certain course of action. This means that instruction
or a whole block of instructions can be executed, repeated or skipped.
1.2.6 Output
The processed data which produced certain result is known as the
output. The output data will be presented in a sheet of paper through
the printer or display on a monitor.
E3062/1/5
Basic Concept And Problem Solving in Programming
Activity 1A
1.3 State the difference between batch mode and interactive mode operation
E3062/1/6
Basic Concept And Problem Solving in Programming
Feedback To Activity 1A
1.2 A set of instructions that tells the computer what to do is called a program.
1.3 In batch mode of operation, the program and the data are typed into the computer
and stored within computer’s memory and processed in its proper sequence.
Large quantities of information can be transmitted into and out of the computer
without the user present while the job being processed. Batch processing can be
undesirable for simple jobs. In interactive mode the user and the computer are
able to interact with each other during computational session.
E3062/1/7
Basic Concept And Problem Solving in Programming
INPUT
Process of designing program can be divided into two phases mainly the
problem solving phase and implementation phase. The problem solving
phase consist of steps 1 through 3 and implementation phase involved steps 4
and 5. While in step 6, documentation is done throughout the process of
designing program.
resolving it. Analyzing the problems will determine the input, output
and information required to solve these problems, as follows:
a. input – data to be processed
b. output – the desired result
c. the constraint and additional features in resolving the
problems
d.
1.3.2 Planning of variables
Variables are simply references to memory locations. A well plan use
of variables will produce an efficient execution of program in terms
of speed and memory utilization.
Activity 1B
Feedback To Activity 1B
KEY FACTS
1.
SELF-ASSESSMENT
You are approaching success. Try all the questions in this self-assessment section
and check your answers with those given in the Feedback on Self-Assessment 1
given on the next page. If you face any problems, discuss it with your lecturer.
Good luck.
Question 1-1
Question 1-2
Question 1-3
Feedback To Self-Assessment
Have you tried the question????? If “YES”, check your answer now:
Question 1-1
i. Declaration
A declarations associates a group of variables with a specific data type. All
variables must be declared before they can appear in executable statements.
ii. Input
A set of information called data entered into the computer from
keyboard, floppy disk, hard disk etc. and stored in a portion of the computer
memory is known as input.
iii. Output
The processed data which produced certain result is known as the output. The
output data is usually presented in a sheet of paper through the printer or
display on a monitor.
Question 1-2
Once the program has been written it must be compiled and executed. This is
accomplished by an editor and compiler. An editor lets us type a program, makes
changes and save it to a file. The compiler then translates the program into a form
that the computer can read. Once the program has been compiled and executed the
presence of errors will be readily apparent. Syntactic and execution errors usually
E3062/1/15
Basic Concept And Problem Solving in Programming
result in the generation of error when compiling or executing a program. Error of this
type is usually quite easy to find and correct. Much more difficult to detect are
logical errors since the output resulting from logically incorrect program may appear
to be error free. Thus a good bit of probing may be required which is known as
logical debugging.
Question 1-3
CONGRATULATIONS!!!!…..
May success be with you
always….