TRENDING TOPICS

×

'goto' Statement in C Language

In C goto statement is used as a jumping statement. Jumping means transferring program control from one statement to another statement in program. A level ( variable name ) is required to use goto statement in c program, level name can be any name except c keyword.

goto statement in c

How goto looks like in C ..?

goto level_name;
............
............
............ // block of code
............
level_name:
statement;

What do you think about output..?

goto in c - block diagram

goto in c

How to use 'goto' in C

  • To use goto statement, level is must.
  • level can be any variable name except c keyword and colon : is must required just after the level_name.
  • Example of level declaration - level_name:
  • to jump on level, goto keyword must followed by level_name.
  • Example of goto statement - goto level_name;
  • goto jumps program control on level_name position.
  • The place of goto and level_name declaration can be accoding to programmer and program requirement, they can be on top to bottom or bottom to top.
  • For best programming experince use goto statement with conditional statement, for example if statement.
  • In large program avoid to use goto statement.
  • Let's see some goto statement programs by taking some example.

goto statement example

Output

1 is odd number
2 is even number
3 is odd number
4 is even number
5 is odd number
6 is even number
7 is odd number
8 is even number
9 is odd number
10 is even number

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)