C language gives a facility to define some labels/markers and one keyword called goto to jump to those labels. Syntax for label and goto statement.

goto <Label name>;
<Label name>:
Name of a label can be defined with the same rule as of a variable name.
int validate_roll(int roll)
  if (roll <= 0) {
    goto not_positive_roll;
  } else if (roll > MAX_ROLL) {
    goto out_of_range_roll;
  } else {
    retun 0;
11    not_positive_roll:
12    printf ("Please give a non-zero positive number.");
13    return -1;
14    out_of_range_roll:
15    printf ("Please roll no. is too large.");
16    return -1;
18  }

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

register vs auto variable, const, sizeof void, if, if-else, if-else-if, label and goto, switch case, compare with ==, execution sequence,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan