C# Sharp Programming Exercises

C# Sharp Exercises: Check whether two integers are equal or not

C# Sharp Conditional Statement : Exercise-1 with Solution

Write a C# Sharp program to accept two integers and check whether they are equal or not.

Sample Solution:-

C# Sharp Code:

using System;  
public class Exercise1  
    public static void Main()  
        int int1,int2;
         Console.Write("Check whether two integers are equal or not:\n");
        Console.Write("Input 1st number: ");  
        int1= Convert.ToInt32(Console.ReadLine());  

        Console.Write("Input 2nd number: ");  
        int2= Convert.ToInt32(Console.ReadLine());  

    if (int1 == int2)
        Console.WriteLine("{0} and {1} are equal.\n",int1,int2);
        Console.WriteLine("{0} and {1} are not equal.\n",int1,int2);

Sample Output:

Check whether two integers are equal or not:                                                               
Input 1st number: 20                                                                                          
Input 2nd number: 20                                                                                          
20 and 20 are equal.

Flowchart :

Flowchart: Check whether two integers are equal or not

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: C# Sharp Conditional Statement Exercise.
Next: Write a C program to check whether a given number is even or odd.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming