Assignment No#1 Question No 1: Describe How Many Types of Program Error Can Occur? Answer: Errors in C/C++
Assignment No#1 Question No 1: Describe How Many Types of Program Error Can Occur? Answer: Errors in C/C++
Assignment no#1
Question no 1:
Describe how many types of program error can occur?
Answer:
Errors in C/C++:
Error is an illegal operation performed by the user which results in abnormal working of the
program.
Programming errors often remain undetected until the program is compiled or executed. Some of
the errors inhibit the program from getting compiled or executed. Thus errors should be removed
before compiling and executing.
The most common errors can be broadly classified as follows.
Type of errors:
1. Syntax errors: Errors that occur when you violate the rules of writing C/C++ syntax are
known as syntax errors. This compiler error indicates something that must be fixed before the
code can be compiled. All these errors are detected by compiler and thus are known as compile-
time errors.
Most frequent syntax errors are:
Missing Parenthesis (})
Printing the value of variable without declaring it
Missing semicolon like this:
Syntax of a basic construct is written wrong.
2. Run-time Errors :
Errors which occur during program execution (run-time) after successful compilation are
called run-time errors. One of the most common run-time error is division by zero also known as
Division error. These types of error are hard to find as the compiler doesn’t point to the line at
which the error occurs.
3. Linker Errors:
1
ISP MULTAN
Osman Liaqat Bhatti BSc Electrical Engineering
BEET 023R19P-03 BEET 2nd Semester
These error occurs when after compilation we link the different object files with main’s
object using Ctrl+F9 key (RUN). These are errors generated when the executable of the program
cannot be generated. This may be due to wrong function prototyping, incorrect header files. One
of the most common linker error is writing Main () instead of main ().
4. Logical Errors:
On compilation and execution of a program, desired output is not obtained when certain
input values are given. These types of errors which provide incorrect output but appears to be error
free are called logical errors. These are one of the most common errors done by beginners of
programming.
These errors solely depend on the logical thinking of the programmer and are easy to detect if we
follow the line of execution and determine why the program takes that path of execution.
5. Semantic Errors:
This error occurs when the statements written in the program are not meaningful to the
compiler.
Question no#2:
Which error is most difficult to locate and remove in c type program?
Answer:
Run-Time Error is most difficult to locate and remove in c type program. In general it is
very difficult to identify logical error in C language, to overcome this problem exception handling
was introduced in object oriented programming language.
2
ISP MULTAN