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 "+". */
- }
semantica si verifica di solito a causa di un uso improprio delle istruzioni del programma.
EX: dobbiamo confrontare due variabili ma invece di usare "==" (operatore relazionale) usiamo "=" (operatore di assegnazione) per errore.
- if( a = b ){ } /* qui invece di fare un confronto di uguaglianza il codice sta effettivamente facendo un'assegnazione. */
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