0% found this document useful (0 votes)
195 views14 pages

Computer Programming: Chapter 2. Problem Solving Using Computer

This document provides an overview of key concepts in computer programming including problem analysis, algorithm development, flowcharting, coding, compilation, execution, debugging, testing, documentation, and common types of errors. It discusses how problem analysis is used to gather information to determine the nature of a problem and potential solutions. It also describes the basic steps to develop algorithms and flowcharts to represent the logic and steps to solve problems. The document outlines the programming, compilation, execution and debugging process and different types of errors that can occur. It concludes with an overview of documentation practices to convey the meaning and purpose of a computer program.

Uploaded by

rajad
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)
195 views14 pages

Computer Programming: Chapter 2. Problem Solving Using Computer

This document provides an overview of key concepts in computer programming including problem analysis, algorithm development, flowcharting, coding, compilation, execution, debugging, testing, documentation, and common types of errors. It discusses how problem analysis is used to gather information to determine the nature of a problem and potential solutions. It also describes the basic steps to develop algorithms and flowcharts to represent the logic and steps to solve problems. The document outlines the programming, compilation, execution and debugging process and different types of errors that can occur. It concludes with an overview of documentation practices to convey the meaning and purpose of a computer program.

Uploaded by

rajad
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/ 14

Computer Programming

Chapter 2. Problem Solving Using Computer

2.1 Problem Analysis


2.2 Algorithm Development & Flowcharting
2.3 Compilation and Execution
2.4 Debugging and Testing
2.5 Program Documentation
Problem Analysis
 Problem analysis is use to gather information that
helps to determine the nature of a problem.
The problem analysis information is used to:
• Determine to resolve the problem.
• Gather sufficient information to communicate with a
system and quickly determine the action or steps that
needs to be taken.
 The method of finding and collecting error
information depends on the state of the problem at the
time of the failure.
Algorithm Development & Flowcharting
Algorithm
•Algorithm can be defined as a sequence of
instructions designed in a manner that, if the
instructions are executed in the specified sequence, the
desired results will be obtained.
•The set of rules that define how a particular problem
can be solved in finite number of steps is known as
algorithm.
•An algorithm is composed of finite set of steps each
of which may require one or more operations.
Algorithm to Add two Numbers:

Step 1 : Start
Step 2 : Input numbers „a‟ and „b‟
Step 3 : Sum=a+b
Step 4 : Display “Sum”
Step 5 : Stop
Algorithm to Find the given number is Even or Odd:

Step 1 : Start
Step 2 : Read number „n‟
Step 3 : Rem=number mod 2
Step 4 : if Rem=0 then
print "even number "
else
print "odd number "
endif
Step 5 : End
Flowchart
• Flowchart is a graphical representation of step by step
solution of a given problem. It represents the program
logic in terms of symbols. It is used by the programmers
to develop the program and system designer to represent
the overall system while analyzing and developing the
system.
• A flowchart consists of a set of flowchart symbols
connected by arrows. Each symbol contains information
about what must be done at that point and the arrows
show the flow of execution of the algorithm, i.e. they
show the order in which the instruction must be
executed.
Basic Flowchart Symbols
Ellipse or Oval : Start / Stop

Parallelogram : Input / Read and


Output / Display

Rectangle : Processing

Diamond : Decision

Arrow line : Flow line

Circle : Connector
Draw Flowchart:

• To Add two Numbers


• To Find the given number is Even or Odd
Compilation and Execution
Coding
Coding is the process of translation from a
detailed design to program statements in a
programming language. The programmers write a
program using language bounded by the rules of that
language.
Compilation and Execution
Source code of any high- level language must be
translated into object code before it is executed. This
translation process is known as compilation or
interpretation, depending on how it is carried out.
Finally, the .exe file is produced and the program is
executed.
Debugging and Testing
Testing
Testing is the process of evaluating a newly
developed program to check if it generates desired
output or not. The testing process may involve several
trails using different test data before the programming
team is satisfied so that program can be released.

Debugging
Debugging is the process of detecting, locating
and removing errors in a program. Mistakes may be
syntax error or semantic error or run- time error.
Types of Error
Syntax error
It is the error in the program‟s grammatical rule
in writing format. If a program contains syntax error,
the program will not produce output. This error is
detected by translator during translation so, it is easier
to correct. For e.g. in C language whenever we do not
use semicolon in a simple statement causes syntax
error.
Semantic error
Semantic error is an error in the concept of the
program. It causes a program to operate incorrectly. If
a program contains only a logical error, the program
will be executed and will also produce output but the
output will not be accurate. For e.g. to calculate area
of circle formula is (pi*r*r) but if we write (2*pi*r)
then it will produce semantic error.

Run- time error


When a program is running or executing, it is
said to be in run- time. A run- time error is an error
that is generated while the program is being executed.
For e.g. a memory leak, where the program takes up
excessive amounts of system memory, then it may
generate run- time error, as it may allow other
programs to be loaded in the memory.
Program Documentation
Documentation is textual information within a program that
helps convey the meaning of the program to human readers
who need to understand, modify, or debug the program.
Forms of Documentation
• Inherent documentation -- "self-documenting" code is the
best form of documentation. Carefully chosen names for
variables, procedures, etc. are extremely important in
conveying their purpose. Code should be presented in a
logical, easy-to-follow manner, conforming to standard
conventions of order and indentation.
• Inline documentation -- occasional comments within the
code, usually to the right, that explain the purpose of that
line of code. Sometimes, a variable or parameter needs more
explanation, or the purpose of a procedure is not
immediately obvious from the name. Assumptions must be
included. (In C, everything from a // until the end of a line is
considered a comment, and the compiler ignores it.)
• Header comments -- a paragraph at the top of a file that
explains the purpose of its contents. This is useful for
someone unfamiliar with the program who needs an
overview.
• External documentation -- information for programmers
wishing to incorporate our code into a larger project. The
functionality of each piece is explained, but the internal
implementation details are not.
• User manual -- information for users of the application on
how to use the features of the program.

You might also like