0% found this document useful (0 votes)
0 views

01 EditingCompilingErrorCheckingExcutionTestingDebugging

The document outlines key concepts in programming, including editing, compiling, error checking, execution, testing, and debugging. It explains the importance of problem statements, language syntax, and the compilation process, detailing types of errors such as syntax, run-time, linker, and logical errors. Additionally, it emphasizes the significance of testing and debugging in ensuring program correctness and reliability.

Uploaded by

randomtp44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

01 EditingCompilingErrorCheckingExcutionTestingDebugging

The document outlines key concepts in programming, including editing, compiling, error checking, execution, testing, and debugging. It explains the importance of problem statements, language syntax, and the compilation process, detailing types of errors such as syntax, run-time, linker, and logical errors. Additionally, it emphasizes the significance of testing and debugging in ensuring program correctness and reliability.

Uploaded by

randomtp44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

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.

Understanding of language syntax and semantics


Even to implement simple program, programmer should know the syntax and semantics
of programming language.
While writing program, programmer should know,
-which are libraries gone required
-Should able to decide data structure and functionality required

Transformation of problem statement in to programming:


Having problem statement and programming language understanding isn’t sufficient to
implement program. First programmer should understand problem and steps to solve it. Next,
convert solution steps in to programming statements. Programmer should able to decide libraries,
data types, types of statements, functionalities and even divide problem statement in to smaller
sub problems for implementation.

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

4.1 Syntax error


Syntax errors are also known as the compilation errors as they occurred at the compilation time.
These errors are mainly occurred due to the mistakes while writing or do not follow the syntax of
the specified programming language. These errors can be easily debugged or corrected.
Commonly occurred syntax errors are:
o If we miss the parenthesis (}) while writing the code.
o Displaying the value of a variable without its declaration.
o If we miss the semicolon (;) at the end of the statement.
#include <stdio.h>
int main()
{
int n1=0; // variable initialization
int n=1
printf("The value of sum is %d, n2);
return 0;
}

4.2 Run-time error


Sometimes the errors exist during the execution-time even after the successful compilation
known as run-time errors.
When the program is running, and it is not able to perform the operation is the main cause of the
run-time error.
The division by zero is the common example of the run-time error. These errors are very difficult
to find, as the compiler does not point to these errors.

#include <stdio.h>
int main()
{
int n1=10; // variable initialization
int n2=0;
int div;
div = n1/n2;
printf(“Division = %d”, div);

return 0;
}

4.3 Linker error


Linker errors are mainly generated when the executable file of the program is not created.
This can be happened either due to the wrong function prototyping or usage of the wrong header
file.
For example, the main.c file contains the sub() function whose declaration and definition is done
in some other file such as func.c. During the compilation, the compiler finds the sub() function
in func.c file, so it generates two object files, i.e., main.o and func.o. At the execution time, if
the definition of sub() function is not found in the func.o file, then the linker error will be
thrown. The most common linker error that occurs is that we use main() instead of main().
4.4 Logical error
The logical error is an error that leads to an undesired output.
These errors produce the incorrect output, but they are error-free, known as logical errors. These
types of mistakes are mainly done by beginners.
The occurrence of these errors mainly depends upon the logical thinking of the developer. If the
programmers sound logically good, then there will be fewer chances of these errors.

#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.”

You might also like