✏️ Explanatory Question
The goto statement in C language is used to transfer control unconditionally from one point in the program to another. It allows jumping to a labeled statement within the same function.
Syntax:
goto label;
...
label:
// Statements to execute
Example:
#include <stdio.h>
int main() {
int num = 5;
if (num == 5) {
goto skip; // Jump to the label "skip"
}
printf("This line will be skipped.\n");
skip:
printf("Jumped to the label using goto.\n");
return 0;
}
goto:goto:if-else, switch-case) instead of goto for better structured programming.