Computer Science, asked by Shreyes2833, 1 year ago

Write a program that will accept two numbers n and m from the user where

Answers

Answered by BhavyaRajput1
1
C Program to Accept two Integers and Check if they are Equal

This is a C program to accept two integers and check if they are equal.

Problem Description
This program accepts two integers and check if they are equal or not.

Problem Solution
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.

Program/Source Code
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");
}
Program Explanation
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”.

Runtime Test Cases
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
Similar questions