Sei sulla pagina 1di 15

E3062/1/1 Basic Concept And Problem Solving in Programming

UNIT 1 Basic Concept and Problem Solving in Programming

OBJECTIVES

General Objective

: To Understand the Concept of Program Characteristics and Steps in Developing Program

Specific Objectives : At the end of the unit you will be able to :    define what is a program. explain the meaning of program structure. discuss steps in programming

E3062/1/2 Basic Concept And Problem Solving in Programming

INPUT

1.0

Basic concept of Programming

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.1

Definition of program A set of instructions that tells the computer what to do is called a program. For example, a word processor is a program written in computer language like C++, that tells the computer what to do when you type in a letter.

1.2

The components of program structure.

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 computers 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

organized into words rather than bytes. Computers also employ auxiliary storage e.g. disks in addition to their primary memories

which allowed information to be stored permanently and can be physically disconnected when not in use.

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 computers 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

TEST YOUR UNDERSTANDING BEFORE YOU CONTINUE WITH THE NEXT INPUT!

1.1 List the characteristics of a well planned program.

1.2 What is a program?

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.1 Integrity, Clarity, Simplicity, Efficiency, Modularity, Generality.

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 computers 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

1.3

Identifying steps in programming

In solving problems of developing program, software development method is used. It consists of several steps which is known as software life cycle, these are: 1. Defining and analyzing problems 2. Planning of variables 3. Drawing of flowchart 4. Program writing 5. Testing and debugging program 6. Documentation of program.

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.

1.3.1 Defining and analyzing problems Programming begin with a specification of problems. This steps is to identify and understand what are the problems to resolve. The problems must be clearly define, explicit and the requirements in

E3062/1/8 Basic Concept And Problem Solving in Programming

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.

1.3.3 Drawing of Flowchart Flowchart represents algorithm in graphic form comprising of geometrical symbols which is interrelated by line of flow.

1.3.4 Program writing In the design of program it should be written as simple as possible. The main objective is to give a clear, readable programs through an orderly and disciplined approach to programming.

1.3.5 Testing and debugging program 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 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

E3062/1/9 Basic Concept And Problem Solving in Programming

logically incorrect program may appear to be error free. Thus a good bit of probing may be required which is known as logical debugging.

1.3.6 Documentation of program Program must be documented for future references and maintenance process. A well documented program will make it easier for the original programmer or other programmer to follow the program logic and design. Program document should consist of : 1. An accurate specification of requirement 2. Detail input, output, constraint and formula for the above problems 3. Algorithm in the form of flowchart or pseudocode 4. Program source complete with comment 5. Sample program which had been run and executed and the tested data. 6. Guideline on how to use the program.

E3062/1/10 Basic Concept And Problem Solving in Programming

Activity 1B

TEST YOUR UNDERSTANDING BEFORE YOU CONTINUE WITH THE NEXT INPUT!

1.4 State the steps in developing program.

1.5 State the components of documenting a program.

1.6 What is a flowchart?

E3062/1/11 Basic Concept And Problem Solving in Programming

Feedback To Activity 1B

1.4 i ii iii iv v vi

Defining and analyzing problems Planning of variables Drawing of flowchart Program writing Testing and debugging program Documentation of program.

1.5 i ii

An accurate specification of requirement Detail input, output, constraint and formula for the above problems

iii iv v

Algorithm in the form of flowchart or pseudo code Program source complete with comment Sample program which had been run and executed and the tested data.

vi

Guideline on how to use the program.

1.6 Flowchart represents algorithm in graphic form comprising of geometrical symbols which is interrelated by line of flow.

E3062/1/12 Basic Concept And Problem Solving in Programming

KEY FACTS
1. Program is a set of instructions that tells the computer what to do is called a program 2. Characteristics of a good program are integrity, clarity, simplicity, efficiency, modularity and generality. 3. Process of designing program can be divided into two phases mainly the problem solving phase and implementation phase.

E3062/1/13 Basic Concept And Problem Solving in Programming

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

a) Briefly describe the components of program structure below. i. ii. iii. Declaration Input Output

Question 1-2

a) Explain the steps taken in testing and debugging of program.

Question 1-3

a) Why are documentation of programs important?

E3062/1/14 Basic Concept And Problem Solving in Programming

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

It is important to document program for future references and maintenance process. A well documented program will make it easier for the original programmer or other programmer to follow the program logic and design.

CONGRATULATIONS!!!!.. May success be with you always.

Potrebbero piacerti anche