go to statement in C


Generally all the statements inside the C program executed in sequence.However decision making statement allows us to control the execution of statements based on some condition.
Goto statement in C is used to alter the normal sequence of the program either conditionally or unconditionally.

Syntax
goto label;
Here,label indicates the point at which control of the program is transfered.
     

Label can be specified anywhere in the main ().
Name of the label must followed by the colon (:) and then followed by the statements. 
If label appears before goto statement then it is known as backward jump. If label appears after goto statement then it is known as forward jump.

Example
Read:
printf("Enter Number");
scanf("%d",&n);
if (n%2==0)
goto Read;
else
printf("%d",n); 
 

Download Projects


Download Programs