Why use of goto…label is not recommended for unconditional jumps


Why use of goto…label is not recommended in C programming

Why use of goto…label is not recommended for unconditional jumps ?

  1. The labelled statement is searched from the very first line of code till the last line of code by the compiler using linear search mechanism. If the labelled statement is found, then the control is transferred to this statement from the goto statement, otherwise a compile time error is reported. The computational overhead is hire as compared to a conditional jump operation due to this linear search mechanism.
  1. Use of goto…label may result an indefinite iteration between the goto statement and the labelled statement. That resulting a sentinel or infinite loop in the program. Thus use of goto…label is not recommended in a C program.


No comments

Powered by Blogger.