This is a C program to accept two integers and check if they are equal.
This program accepts two integers and check if they are equal or not.
1. Take the two integers as input.
2. Using if,else statements check if they are equal or not.
3. Print the output accordingly and exit.
Here is source code of the C program to accepts two integers and check if they are equal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to accept two integers and check if they are equal
*/
#include <stdio.h>
void main()
{
int m, n;
printf("Enter the values for M and N\n");
scanf("%d %d", &m, &n);
if (m == n)
printf("M and N are equal\n");
else
printf("M and N are not equal\n");
}
1. Take the two integers as input and store it in the variables m and n respectively.
2. Using if,else statements check if m is equal to n.
3. If they are equal, then print the output as “M and N are equal”.
4. Otherwise print it as “M and N are not equal”.
Case:1 Enter the values for M and N 3 3 M and N are equal Case:2 Enter the values for M and N 5 8 M and N are not equal
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Books in C Programming, Data-Structures and Algorithms
- Check Computer Science Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check C Books
- Practice BCA MCQs