Explanatory Question
What is the use of goto statement?
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.
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 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.First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.