C Program to Check if Two Input Integers are Same or Not

In this article, we will learn how to determine/check if two input integers are the same or not using the C programming language. To write this program we will need some basic C programming concepts including conditional (if-else) statements.

Algorithm – Check if Two Input Integers are Same or Not

  • In the main function, declare two variables a and b.
  • Ask two numbers to the user and keep those into a and b variables using the scanf() function.
  • Write a simple condition to check if both numbers are equal or not. If it evaluates true indicate that otherwise indicate the false indication.

C Program to Check if Two Input Integers are Same or Not

#include <stdio.h>
int main() {
    int a, b;

    printf("Enter the first Interer: ");
    scanf("%d", &a);
    printf("Enter the Second Integer: ");
    scanf("%d", &b);

    if (a == b) {
        printf("The Input Ingegers %d and %d are Equal\n", a, b);
    } else {
        printf("The Input Integers %d and %d are not Equal\n", a, b);
    }

    return 0;
}
  1. Save the above with in a file with .c file extension. Then run the program using your favorite IDE. The you can see the output:
Sample Input Sample Output
Enter the first Interer: 5 Enter the Second Integer: 8 The Input Integers 5 and 8 are not Equal
Enter the first Interer: 12 Enter the Second Integer: 12 The Input Ingegers 12 and 12 are Equal

General Learning Output (GLO)

  • Declaring multiple integer variable with a single statement.
  • Taking input using scanf() function and put the input value into variables.
  • Basic application of if-else statement.
  • Display variable value with additional text into console using printf() function.
  1. C program to print Integer & Decimal number given by user
  2. C Program to perform all arithmetic calculation
  3. C program to ask two numbers and find their sum
  4. C program to check a number is even, odd or zero
  5. C program to swap between two numbers
  6. C program to sum of natural numbers up to N
  7. C program to calculate the factorial of a number
  8. C program to make a multiplication table
  9. C program to calculate GCD of two numbers
  10. C program to calculate LCM of two numbers
  11. C program to count number of digits in a number
  12. C program to reverse a integer number
  13. C program to find the power of a number
  14. C program to check whether a number is palindrome or not
  15. C program to count and print prime numbers up to the N
  16. C program to check armstrong numbers
  17. C program to check armstrong numbers between two integers
  18. C program to find factors of a number
  19. C program to fined the size of all data types
  20. C program to print largest number among three numbers
  21. C program to check a number is positive or negetive
  22. C program to calculate the factorial of a number
  23. C program to form any kind of pyramid and stracture
  24. C program to find all the prime numbers between two numbers
  25. C program to check whether a number is prime or not
  26. C program to make a simple calculator
  27. C program to calculate the perimeter of a rectangle
  28. C program to calculate the area of a rectangle
  29. C program to calculate the diameter and area of a circle
  30. C program to convert kilometer to meter and centimeter
  31. C program to convert temperature celsius to fahrenheit
  32. C program to convert temperature fahrenheit to celsius
  33. C program to ask for days and convert into years, week and days
  34. C program to calculate the square root of a given number
  35. C program to find third angle of a triangle where two angles are given
  36. C program to calculate the area of a triangle
  37. C program to calculate area of an equilateral triangle
  38. C program to calculate average and percentage of result
  39. C program to calculate simple loan interest
  40. C program to compound loan interest
  41. C program to display fibonacci series of a number
  42. C program to swap two numbers without using third variable
  43. C program to print Hello World without using semicolon
  44. C program to insert assembly code and run it
  45. C program to printf Hello world without main() function
  46. C program to to calculate the multiplication of two matrix
  47. C program to convert decimal numbers into binary
  48. C program to form a triangle made with alphabet
  49. C program to form a triangle made with numbers
  50. C program to form a fibonacci triangle
  51. C program to convert a number into charecters

Happy Coding 🙂