C# program to demonstrate the use of goto statement
Program.cs
int n;
Console.Write("Enter a number ");
n = Convert.ToInt32(Console.ReadLine());
if (n % 2 == 0)
{
    goto EVEN;
}
else
{
    goto ODD;
}
EVEN: Console.WriteLine(n + " is an EVEN number");
return 0;
ODD: Console.WriteLine(n + " is an ODD number");
return 0;
Output
kodingwindow@kw:~/csharp$ dotnet run
Enter a number 9
9 is an ODD number
kodingwindow@kw:~/csharp$ 
Advertisement