goto
C programming, the goto statement is used to transfer control to a labeled statement within the same function. It provides a way to jump to a specific location in the code, skipping any intermediate statements. The general syntax of the goto statement is as follows:
Here's an example that demonstrates the usage of the goto statement:
#include <stdio.h>
int main() {
int num;
printf("Enter a positive number: ");
scanf("%d", &num);
if (num <= 0) {
goto error;
}
printf("The number is: %d\n", num);
return 0;
error:
printf("Invalid number entered!\n");
return 1;
}