0
5.3kviews
Explain following statement with example, (i) goto (ii) continue
1 Answer
written 8.3 years ago by |
A goto statement in C programming provides an unconditional jump from the 'goto' to a labeled statement in the same function.
Syntax
goto label;
..
.
label: statement;
Example
goto label;
printf (“Hey”);
label: printf(“Bye”);
Output
Bye
The first printf statement wasn’t read as the goto statement caused the compiler to jum directly to the labelled statement.
ii) continue;
This statement is used when an iteration of a loop is completed but the loop is still to be used.
Syntax
While (condition)
{
Statements;
Continue;
Statements;
}
Example: the following will print odd numbers only.
I=0;
While (I<10)
{
I++;
if(I%2==0)
continue;
else
printf(“%d “, I)
}
Output
1 3 5 7 9