01 EditingCompilingErrorCheckingExcutionTestingDebugging
01 EditingCompilingErrorCheckingExcutionTestingDebugging
Editing
Editing is the process of writing or modifying written program to solve a given problem.
In order to write program, required following
A problem Statement
Understanding of language syntax and semantics
Ability to transform, problem statement in to programming
A problem Statement
First thing you need is a problem statement. Even, when you start learning any
programming language, first program is to print ‘Hello World’; program to print ‘Hello World’
is problem statement. Problem statement is can be simple as print ‘Hello World’ to very complex
program to launch satellite in the space.
2. Compiler
A compiler is a special program that processes statements written in a particular programming
language and turns them into machine language or "code" that a computer's processor uses.
Typically, a programmer writes language statements in a language such as Pascal or C one line at
a time using an editor.
The file that is created contains what are called the source statements. The programmer then runs
the appropriate language compiler, specifying the name of the file that contains the source
statements.
When executing (running), the compiler first parses (or analyzes) all of the language statements
syntactically one after the other and then, in one or more successive stages or "passes", builds the
output code, making sure that statements that refer to other statements are referred to correctly in
the final code.
Traditionally, the output of the compilation has been called object code or sometimes an object
module.. The object code is machine code that the processor can execute one instruction at a time.
3. Compiling or Compilation:
The compilation is a process of converting the source code into object code. It is done with the
help of the compiler.
The compiler checks the source code for the syntactical or structural errors, and if the source
code is error-free, then it generates the object code.
The c compilation process converts the source code taken as input and produces the object code
or machine code.
The compilation process can be divided into four steps, i.e., Pre-processing, Compiling,
Assembling, and Linking.
4. Error Checking:
Errors are the problems or the faults that occur in the program, which makes the behavior of the
program abnormal, and experienced developers can also make these faults.
Programming errors are also known as the bugs or faults, and the process of removing these bugs
is known as debugging.
These errors are detected either during the time of compilation or execution. Thus, the errors
must be removed from the program for the successful execution.
Types of error:
1. Compiler time/Syntax error
2. Run Time Error
3. Linking error
#include <stdio.h>
int main()
{
int n1=10; // variable initialization
int n2=0;
int div;
div = n1/n2;
printf(“Division = %d”, div);
return 0;
}
#include <stdio.h>
int main()
{
int n1=0; // variable initialization
int n2=1;
if(n1==n2); // logical error, semicolon after conditional statement
{
printf(“Both numbers are equal”);
}
printf("The value of sum is %d", n1+n2);
return 0;
}
5. Execution
The executable code is sent to loader which loads it into memory and then it is executed. After
execution, output is sent to console.
6. Testing
Testing is the process of finding errors (“bugs”) in a program
Testing can increase your confidence that a program is error-free
Testing can find the presence of error, but in general cannot prove the absence of error
Testing is small program is much easier than testing large programs
When testing the code with branches, provide inputs that test all code section of the if
statement.
Programmer should test your program with expected and unexpected (invalid) inputs:
o Programmer should know how program will perform with good data as well as
bad data
o Unexpected values may be negative, extremely large, or extremely small values.
Programmer should test your test program with boundary values, i.e. values at and around
a values for which the behaviour of a program should change
o For example, good boundary condition test values for Age (for boundary value
18) in the code would be 17, 18, 19
o For real valued boundaries like 98.6, test with close real values like 98.5999, 98.6
and 98.6001
When testing loops, provide inputs that cause the loop to repeat zero, one and many
times.
7. Debugging
Debugging is the process of location and correcting error in a program
Debugging is problem-solving and often can be very challenging.
Thinking carefully about program is often best step when debugging
Programmer can help minimize time spend debugging by:
o Starting with good program design
o Coding carefully, and
o Testing your program as program write.
The development of good debugging skills comes from experience, Therefore, make sure
you learn from your mistakes.
It often helps to have someone else look at your code when debugging.
General rule for all debugging
o “When in doubt, print it out.”