You are on page 1of 21

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH

Name : Gandi Govinda Naidu


Designation : Head of Computer Engg Section
Branch : Computer Engg
Institute : Govt.Polytechnic for Women,
Bheemunipatnam
Year / Semester : III Semester
Subject : UNIX & C
Subject Code : CM-304
Topic : Understand Programming Methodology

Duration : 50 Min
SubTopic : Steps in Problem Solving
Teaching Aids : PPT, Animations, Photographs

CM304.26 1
Objective

On completion of this period, you would be able to


learn

 How to prepare a solution for a given problem.


 What are the errors that occur in the problem.

CM304.26 2
What is a Computer program?

A set of instructions written by the


user/programmer.

 Programming
The process of writing a program.
 Before programming
The problem to be solved needs preparation.

CM304.26 3
What is a computer ?

 Neither think nor make any judgment on


its own.
 Be instructed by the user/ programmer to
solve a problem.
The user/programmer
 instruct the computer exactly what to do.
 in a step-by-step fashion.

Hence before programming


 user/programmer has to analyze the problem.

CM304.26 4
Contd..

Problem analysis
 The process of achieving the required level of
satisfactory details of the problem.

User/programmer should follow


 A step-by-step procedure.
 Prepare a program from a given problem.

CM304.26 5
The steps involved in problem solving.

 Problem specification
 Outlining the solution
 Representing an algorithm and flowchart
 Transforming algorithm into a program
 Removing errors

CM304.26 6
Problem Specification

 Thoroughly understand the problem


 Know exactly what is to be done
 Carefully identify the input(s)
 Carefully identify the processing
 Based on the questions asked
 Carefully identify the output(s)
 The input, processing and output
most important collection of information

CM304.26 7
Outlining the solution

 After getting clear understanding on the problem


find a solution method to solve the problem.
 There may be several solution methods.
 Study them based on the following criteria
Computer time needed
Complexity
Error prone
 When there are no specific solutions
Either a new method must be developed
or
The problem be simplified to get a feasible
solution.

CM304.26 8
Removing Errors
Errors occur due to mistakes done in coding.
Errors cause wrong results.
Errors must be detected and corrected.
Program verification.
Checking whether the program is correct or not.
Debugging:
 Process of detecting and removing the errors.
Note:bug means an error in a program.

CM304.26 9
Types of possible errors in a program

 Syntax errors
 Run-time errors
 Logical errors

CM304.26 10
Syntax errors

 Occur due to wrongly typed programs.


i.e., not according to the syntax or
grammatical rules.
 Detected at the time of compiling the
program.
 Error messages are displayed.

CM304.26 11
Examples for syntax errors

For example in English language


 Correct sentence : There is a cat.
 Incorrect sentence : There a cat
 Grammatical errors : missing verb and full stop(.)
For example in C language
 Correct statement : a=(b+(c+d))/2;
 Incorrect statement : a=b+(c+d))/2
 Syntax errors : missing left parenthesis
and semicolon.

CM304.26 12
Run-time Errors

 Occur due to violation of boundary rules.


 Data manipulation or memory access.
 Detected at the time of program execution.
Examples
o Divide by zero.
o Square root of a negative number.
o Logarithm of a negative number.
o Mixing of various data types.

 Error messages are not displayed.

CM304.26 13
Logical Errors

 Occur due to logically incorrect statements in the


program.
 Very difficult to detect.
 Can be detected only after careful observation of
the output.
 To be conducted through review of each logical
group of statements.
 If not detected, use tracing technique.
Tracing involves
 Taking printout of certain intermediate results.
 Identifying errors by viewing these results.
CM304.26 14
Examples for Logical errors

 Consider the following statement that calculates


multiplication of two numbers A=B+C;
 The above statement is syntactically correct.
Logically incorrect because of using “+” in place
of “ * “.

CM304.26 15
Summary

In this class , you have learnt about

 What are the errors that occur in the solution.


 How to prepare a solution for a given problem.

CM304.26 16
Quiz

1.What is needed before programming?

a) Write algorithm
b) Draw flowchart
c) Analyze the problem
d) None of them

CM304.26 17
Quiz

1.What is needed before programming?

– Write algorithm
– Draw flowchart
– Analyze the problem
– None of them

CM304.26 18
Quiz

2.Important collection of information in


problem specification is ---

a) Input
b) Processing
c) Output
d) All the above

CM304.26 19
Quiz

2.Important collection of information in


problem specification is ---

• Input
• Processing
• Output
• All the above

CM304.26 20
Frequently Asked Questions

1. List out the steps involved in problem solving.

2. Explain the steps followed to solve a given


problem ?

3. List and explain the errors that may occur in a


program.

CM304.26 21

You might also like