Simple C# Program to Compare Two Integers for Equality

This sample code allows user to input two integers and checks if they are equal. It uses basic input/output operations and an if-else condition to determine equality.

Source Code 💻

using System;

class Program
{
    static void Main()
    {
        // Prompt user to enter the first integer
        Console.Write("Enter the first integer: ");
        int num1 = Convert.ToInt32(Console.ReadLine());

        // Prompt user to enter the second integer
        Console.Write("Enter the second integer: ");
        int num2 = Convert.ToInt32(Console.ReadLine());

        // Check if the two integers are equal
        if (num1 == num2)
        {
            Console.WriteLine("The two integers are equal.");
        }
        else
        {
            Console.WriteLine("The two integers are not equal.");
        }
    }
}

🔚 end of document 🔚