CodesJava

Easy learning with example program codes

C Goto


C goto statement is used to jump to a specified label in the code every time, without any condition.

Syntax:

loop/conditions statements

{

statements;

goto;

}

Example:

#include <stdio.h>
 
void main()
{
int i,n;
printf ("Enter a number: ");
scanf ("%d",&n);
 
less:
printf ("less than 5");
 
if (i < 5)
goto less;
else
{
printf ("%d", i);
}
}

Output

Enter a number: 4
less than 5
Posted in C   
Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki