Errors in a Code
Hello guys, you must have been, so far doing all the zig-zag with
keyboard to compile your program. But sometimes you may encounter some
errors, to which you would have nod your head up to your code without even
trying to understand what exactly was the problem, right?
Well today we will discuss about, how missing out the tinniest thing which
plays a great role in compilation of your code.
Errors in C / C++ / Java Language
There are total three types of error in these languages :
1) Compile Error
2) Run Time
Error
3) Logical Error
Compile Error:
These errors present themselves on the output screen at the time of compilation of the program. They can be classified into two
1. Syntax Error : When you break out the rule of the C programming language, our compiler will show Syntax Error.
Eg, int a,b:
This will produce syntax error as the program is terminated by : rather than ;
2. Semantic Error : This error presents himself to the compiler when the statements written in the program are not meaningful to the compiler.
For eg, b+c=a;
In
the above statement we are trying to assign value of a in the value obtained by
summation of b and c which has no meaning in c. The correct statement will be
a = b+c;
Run Time Error:
Due to some illegal operation performed in the program give rise to run
time errors that occur during the execution of the program.
Examples of some illegal operations that may
produce runtime errors are:
- Dividing a number
by zero
- Trying to open a file which is not created
- Lack of free memory space
Occurrence of these errors may stop program execution, so to
encounter this, programs should be written such that they are able to handle
such unexpected errors and rather than terminating unexpectedly, they should be
able to continue operating. This ability of the programs is known as robustness and
the code used to make programs robust is known as guard code as
it guards program from terminating abruptly due to occurrence of execution
errors.
Logical Error
Logical errors are in the output screen as undesired output
and are caused by the illogical way applied in the program to produce the
desired output.
Also, compiler doesn’t detect this error, and thus, you have to check out your whole code, line by line.
If you still have any doubt on this topic then do come to us via email "sophomoretechs@gmail.com" or via instagram "@coding.winds".
We also have an article on space complexity and time complexity , do give them a read.
No comments:
Post a Comment