Introduction To C: Integrated Programme in Management
Introduction To C: Integrated Programme in Management
F= P (1 + i)n
where F represents the future accumulation of money
(including the original sum, P, which is known as the
principal) and
GENERAL OUTLINE
Declare
{
/* declare the program variables */
/* read i n values f o r P, r and n */
}
5
/* compound i n t e r e s t calculations */
main( )
{
/* declare p, r, n, i and f to be floating-point variables */
/* write a prompt for p and then read in its value */
/* write a prompt for r and then read i n its value */
/* write a prompt for n and then read in its value */
/* calculate i= r/100 */
/ * calculate f = p (1 + i ) " as follows:
f = p * pow((l+i),n)
BOTTOM-UP STRATEGY
Useful
HYBRID STRATEGY
In
SYNTACTIC
ERROR
SYNTACTIC ERROR
Syntactic
Compilation/Execution Error
Common Error
. Improperly declared variables
10
HOW MANY
SYNTACTIC
ERRORS ??
13
16
17
CLEAN CODE
CLEAN CODE
#include <stdio.h>
#include <math.h>
main( )
{
float p, r, n, i,f;
/* read input data (including prompts) */
printf(P1ease enter a value for the principal (P): " ) ;
f = p * pow((1 + i ) , n ) ;
21
22
23
24
25
26
27
EXECUTION
ERROR
30
31
a= 1.0
b=2.0
c=3.0
DOMAIN ERROR
33
b=1 El 0
c=1E36
35
DEBUGGING
TECHNIQUE
ERROR
37
40
OUTPUT
When the altered program was executed with the
same three input values, the error message did not
appear (though the displayed values for x1 and x2
did not make any sense).
Thus, it is clear that the source of the original
error message lies in one of these three statements
41
MODIFIED PROGRAM
42
OUTPUT
43
44
OUTPUT
45
WATCH VALUE
Value of a variable / expression which is displayed
continuously as the program executes.
Monitoring changes in a watch value as they occur,
in response to the program logic.
BREAKPOINTS
Temporary Stopping Point within a program.
Each breakpoint is associated with a particular
instruction within the program.
Program execution will temporarily stop at the
breakpoint, before the instruction is executed.
STEPPING
Execution of one instruction at a time ( typically
by pressing a function key to execute each
instruction).
Stepping through an entire program, one can
determine which instructions produce erroneous
results or generate error messages.
Stepping is often used with Watch Values
(allowing you to trace the entire history of a
program as it
Executes).
Observe changes to watch values as they happen.
48
DEBUGGING
49
DEBUGGING
50
DEBUGGING
51
Questions
52
Questions
53
Thank You!