C program to demonstrate the use of goto statement
codeaft.c
#include <stdio.h>
int main()
{
    int n, a;
    printf("Enter a number ");
    scanf("%d", &n);
    if (n % 2 == 0)
    {
        goto EVEN;
    }
    else
    {
        goto ODD;
    }
EVEN:
    printf("%d is an EVEN number\n", n);
    return (0);
ODD:
    printf("%d is an ODD number\n", n);
    return 0;
}
Output
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out Enter a number 6 6 is an EVEN number codeaft@codeaft:~$
Comments and Reactions