adplus-dvertising

C program to check whether two numbers are equal or not

frame-decoration

C program to check whether two numbers are equal or not

Problem Description

This C program accepts two integers and check if they are equal. Equality operator (==) is used to compare the given two numbers.

C program to check whether two numbers are equal or not - Source code
     
                
  /* C program to accept two integers and check if
 they are equal*/

#include <stdio.h>
void main()
{
    int num1, num2;

    printf("Enter the two integer numbers\n");
    scanf("%d %d", &num1, &num2);
    if (num1 == num2)
        printf("The two numbers are equal\n");
    else
        printf("The two numbers are not equal\n");
}

     
      

Program Output

Case 1:

Enter the two integer numbers
76464
67890
The two numbers are not equal

Case 2:

Enter the two integer numbers
8521
8521
The two numbers are equal

Program Explanation

1. Take the two integers as input and store it in the variables num1 and num2 respectively.

2. Compare them using the equal to (==) operator.

3. If they are equal, then print the output as “The two numbers are equal”.

4. Otherwise print it as “The two numbers are not equal”.