In the world of programming many times, we have to verify that if the two numbers are equal or not. In this article, we are going to perform an equality check for two numbers in C.
Problem Statement- WAP that checks whether the two numbers entered by the user are equal or not.
The Importance of Checking Equality
Verifying whether the two numbers are equal or not is a fundamental operation in programming. It is frequently used in decision-making processes, conditional statements, and algorithmic implementations.
C Program to Check Equality of Two Numbers
Let’s write a C program that checks the equality of two numbers entered by the user.
#include <stdio.h>
void main()
{
int n1, n2;
printf("Enter the first number ");
scanf("%d", &n1);
printf("Enter the second number ");
scanf("%d", &n2);
if (n1 == n2)
{
printf("The entered numbers are equal");
}
else
{
printf("The entered numbers are not equal");
}
}
Output
The above C program checks whether two numbers entered by the user are equal or not by using the if else statement in C.
Happy Coding
1 thought on “C Program to Check Equality of Two Numbers”