Dr. A.P.J. Abdul Kalam Technical University, Lucknow
KCS101 / KCS201 Programming for Problem Solving - Using C Language
Lab Exercises
6. Write a program that checks whether the two numbers entered by the user are equal or not.
/*
File: Prgrm06.c
Author: Aditya Saini
Date: Sept 18, 2019
Description: Program to check whether two numbers are equal or not.
*/
#include <stdio.h>
int main (void)
{
int number_1, number_2;
//Input numbers.
printf ("Input first number: ");
scanf ("%d", &number_1);
printf ("Input second number: ");
scanf ("%d", &number_2);
//Input numbers.
printf ("Input first number: ");
scanf ("%d", &number_1);
printf ("Input second number: ");
scanf ("%d", &number_2);
//Checking whether number_1 is equal to number_2 and output the result.
if (number_1 == number_2)
{
printf ("Numbers are equal.");
}
else
{
printf ("Numbers are not equal");
}
{
printf ("Numbers are equal.");
}
else
{
printf ("Numbers are not equal");
}
};
Output
Input first number: 15
Input second number: 17
Numbers are not equal.
No comments:
Post a Comment
Please do not post spam links.