How to solve errors in coding
Debugging is the only key to find out and solve the errors in coding.
Errors can be anything. It can be:-
- Syntax errors
- Logical errors
- semantic errors
Syntax errors is the most common error that we usually do but it is very easy to find out(except few language) and debug.
We usually used to forget “;” at the end of program statement.
- int a = 0 // ; is missing
Logical errors is the most difficult to find out error but we usually think that i himself has developed the logic and coded for it. so there is no chance for logical error and we usually ignore it.
- int CalculateRectangleArea( int length, int breadth)
- {
- return length + breadth;
- /* instead of "*" we use "+". */
- }
semântica ocorre normalmente devido a um uso impróprio das instruções do programa.
EX: temos de comparar duas variáveis mas em vez de usar "==" (operador relacional) usamos "="(operador de atribuição) por engano.
- if( a = b ){ } /* aqui em vez de fazer comparação de igualdade o código está de facto a fazer trabalho. */
So before solving errors in coding first see the errors carefully and find out whether it occurring due to syntax , logical and semantic errors.
put debug point wherever in code you feel that may be due to this line error is coming.
Enjoy