The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
goto statement in c sometimes called as goto operation in other languages like php.
C programming introduces a goto statement by which you can jump directly to a line of code within the same file.
goto Label; . . Label: { statement n; }
The following flowchart will clearly demonstrate, how goto statement works
Let's take a look at the goto statement in action. In the following program we will print whether the number is positive or negative using goto statement
#include <stdio.h> int main() { int num; printf("Enter a positive or negative integer number:\n "); scanf("%d",&num); if(num >= 0) goto pos; else goto neg; pos: { printf("%d is a positive number",num); return 0; } neg: { printf("%d is a negative number",num); return 0; } }
In this program, the user entered number is checked for positive or negative number. If the user entered number is positive, the control is passes to pos : by goto statement. If the user entered number is negative, the control is passes to neg : by goto statement.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019