0% found this document useful (0 votes)
7 views5 pages

ch-2

Uploaded by

Chamu Ndeeswari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
7 views5 pages

ch-2

Uploaded by

Chamu Ndeeswari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

1

Unit-2 Chapter-2 programming methodology


1. what is a good program?
Ans: A Good Program means that it should produce correct and faster results,
taking into account all the memory constraints
2. What is an identifier?
Ans:
 Identifiers are user defined names.
 They are used to name things.
 A name is associated with a function or data object (constants and variables)
and used to refer to that function or data object.
Identifiers are made up of letters (A-Z, a-z), digits (0-9), and the
underscore character ( _ ). They, however, must begin with a letter or underscore
and not with a digit.
a. Give meaningful name for variable (data – object) and function.
b. Use proper names for constants
c. Do not use same name like custom, customer or account, accountant.
d. Do not use one letter identifiers.
3. How to write comments in a program?
 Ans: Comments are usually added with the purpose of making the source code
easy to understand.
 They are generally categorized as either „block comment‟ or „line comment‟.
 Block comment is implemented in python by “”” and “”” and line comment is
implemented by #.
4. What is the purpose of expression? Explain with an example.
 Ans: Expressions are used to implement a particular task.
 It is a combination of Operators,Operands and Constants. Any expression used
in the program should be understood by the user.
 The followings are some of the points to be kept in mind while using
expressions in a program.
(i) Use library functions to make programs more powerful
Example
To find output = x6
Output = X *X * X * X * X * X
We can use output = power (X, 6)
(ii) Follow simplicity to maintain the clarity of expression
Example
X = A+B – U +VY
A-B X+Y
Then, we can write
X1 = (A+B) / (A-B)
X2 = (U+V*Y) / (X +Y)
X = X1 –X2
(iii) Avoid program tricks usage, whose meaning is difficult to understand by the
user.
5. Write and explain all steps of programming methodology.(or)
13. Write all steps of program methodology?
Ans: Programming means a problem solving activity, which
consists of four steps. They are;
(i) Understanding the problem;
(ii) Devising a plan;
(iii) Executing the plan; and
(iv) Evaluation
2

(i) Understanding the problem;


The first step is to understand the problem well. It may be very difficult to
understand the problem but it is crucial. In general, one must find out the output
from the given data (input data) and assess the relationship between input and
output data. It is also important to verify whether the given information is sufficient
to solve the problem or not.
(ii) Devising a plan;
It means drawing an action plan to solve the problem, once understood. A plan is
devised from data processing to the result according to the relationship that links
both of them. If the problem is trivial, this step will not require much thinking.
(iii) Executing the plan; and
Once the plan is defined, it should follow the plan of action completely and each
element of the plan should be checked as it is applied. In the course of execution, if
any part of the plan is found to be unsatisfactory, the plan should be revised.
(iv) Evaluation
Finally, the result should be examined in order to make sure that it is valid and that
the problem has been solved completely.
6. Differentiate between runtime errors and logical errors.

RUNTIME ERRORS LOGICAL ERRORS


 A runtime error is an error  Programmer makes errors while writing
that causes abnormal program that is called „logical error‟. It
termination of program is an error in a program's source code
during running time. that results in incorrect or unexpected
 In general, the dividend is result.
not a constant but might be  It is a type of runtime error that may
a number typed by you at simply produce the wrong output or
runtime. may cause a program to crash while
In this case, division by running.
zero is illogical.  The logical error might only be noticed
Computers check for a "division during runtime, because it is often
by zero" error during program hidden in the source code and are
execution, typically harder to find and debug.
 so that you can get a = 100
a"division by zero" error while a < 10:
message at runtime, which a=a+1
will stop your program print a
abnormally.
This type of error is called runtime
error.
Example
(a) A=10
B=0
print A/B

7. Define documentation.
 Ans: The documentation includes the problem definition, design documents, a
description of the test perform, a history of the program development and its
different versions and a
user‟s manual.
 Such a manual is designed for a naive user and illustrates the preparation of
input data, running the program and obtaining & interpreting the results.
8. What is program maintenance?
3

 Ans: All activities that occur after a program operation are part of the program
maintenance.
 Many large programs have long life span that often exceed the lifetime of the
hardware they run on.
 Usually, the expenditure for the program maintenance will be more than the
developmental cost of the program
9. Define modular programming.
 Ans: Modular Programming is the act of designing and writing programs as
functions (a large program is divided into the small individual components) that
each one performs, a single well-defined function, which has minimal
interaction between the sub-programs.
 It means that the content of each function iscohesive and there is low coupling
between them.
 There are two methods available for modular programming. They are: top-
down design and bottom-up design.
10. Differentiate between top down and bottom up methods of modular
programming.
Top-Down design Bottom-up design
The principles of top-down design Bottom-up design is just the opposite of top-
dictate that a program should be down design.
divided into a main module and It refers to a style of programming, in which,
its related module. an application is constructed with existing
Each module should also be primitives of the programming language and
divided into sub modules then gradually more and more complicated
according to software features are added till applications are written.
engineering and programming In other words, initiating the design with
style. simple modules and then build them into more
The division continues till the complex structures ending at the top is bottom-
module consists only of an up design
elementary process that is
intrinsically understood and
cannot be further sub-divided.
11. Explain types of errors with examples.
Ans: There are three types of errors generally occur during compilation and
running a program. They are
(i) Syntax error; (ii) Logical error; and
(iii) Runtime error.
12. How to maintain programs?
Ans: The program maintenance includes the following:
Finding and eliminating previously undetected program errors;
Modifying the current program, often to improve its performance, or to adapt to
new laws or government regulations, or to adapt to a new hardware, or to a new
operating system;
Adding new features or a better user interface, or new capabilities to the program;
And Updating the documentation.
Maintenance is an important part of the life cycle of a program. It is also important as
far as documentation is concerned, since any change pertaining to a program will
require updating of internal as well as external documentation. Maintenance
documentation will include results of the program development steps, design
4

documents, program code and test information.


14. What do you mean by clarity and simplicity of expression?
Ans: Expressions are used to implement a particular task. It is a combination of
Operators,
Operands and Constants. Any expression used in the program should be understood
by
the user. The followings are some of the points to be kept in mind while using
expressions in a program.
(i) Use library functions to make programs more powerful
Example
To find output = x6
Output = X *X * X * X * X * X
We can use output = power (X, 6)
(ii) Follow simplicity to maintain the clarity of expression
Example
X = A+B – U +VY
A-B X+Y
Then, we can write
X1 = (A+B) / (A-B)
X2 = (U+V*Y) / (X +Y)
X = X1 –X2
(iii) Avoid program tricks usage, whose meaning is difficult to understand by the user.
15. What do you mean by flexibility?
Ans: A program should be flexible enough to handle most of the changes without
having to
rewrite the entire program. A flexible program is used to serve many purposes. For
example, CAD (Computer Aided Design) software is used for different purposes such
as; engineering drafting, printing circuit board layout and design, architectural
design, technical drawing, industrial art, etc. Most of the programs are being
developed for certain period and they need updation during the course of time
16. Explain all steps of problem solving process.
Ans: The problem solving process starts with the problem specifications and ends
with a concrete (and correct) program. Programming means a problem solving
activity, which consists of four steps. They are;
(i) Understanding the problem;
(ii) Devising a plan;
(iii) Executing the plan; and
(iv) Evaluation
Understanding the problem
The first step is to understand the problem well. It may be very difficult to
understand the problem but it is crucial. In general, one must find out the output
from the given data (input data) and assess the relationship between input and
output data. It is also important to verify whether the given information is sufficient
to solve the problem or not.
Devising a plan
It means drawing an action plan to solve the problem, once understood. A plan is
devised from data processing to the result according to the relationship that links
both of them. If the problem is trivial, this step will not require much thinking.
Executing the plan
Once the plan is defined, it should follow the plan of action completely and each
element of the plan should be checked as it is applied. In the course of execution, if
any part of the plan is found to be unsatisfactory, the plan should be revised.
5

Evaluation
Finally, the result should be examined in order to make sure that it is valid and that
the problem has been solved completely.
17. What is indentation? Explain with an example.
Ans: Leading white space (spaces and taps) at the beginning of each statement,
which is used to determine the group of statement, is known as „indentation‟.
Example
If A > B :
print „A is Big‟ # Block1
else:
print „B is Big‟ # Block2
In the above example,
if statements are a type of code block. If the „if‟ expression evaluates to true, then
Block1 is executed, otherwise, it executes Block2. Obviously, blocks can have
multiple lines. As long as they are all indented with the same amount of spaces, they
constitute one block.
18. What do you mean by debugging?
Ans: Debugging is the process of finding and correcting the errors in the program
code.
19. What is the use of self documenting code in programming?
Ans: The source code, which uses suitable name for the identifiers (variables and
methods), is called self-documenting code. Also, giving proper name for variables
and methods would tell the reader of your code clearly -what is it doing? Hence, a
good program must have a self-documenting code.
20. What is the purpose of giving meaningful name for identifiers?
Ans: A name is associated with a function or data object (constants and variables) and
used to refer to that function or data object, . Also, giving proper name for variables
and methods would tell the reader of your code clearly -what is it doing?
**************************************************************

You might also like