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("\n\n");
Console.Write("Check whether two integers are equal or not:\n");
Console.Write("-------------------------------------------");
Console.Write("\n\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);
else
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.
Pictorial Presentation:
Flowchart :
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?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework