Write a program to relate 2 integers entered by the user as equal to, less than or greater than.
Input and Output Format:
Input consists of 2 integers.
Refer sample input and output for formatting specifications.
All text in bold corresponds to the input and the rest corresponds to output.
Sample Input and Output 1:
Enter the first number
6
Enter the second number
8
6 is less than 8
Sample Input and Output 2:
Enter the first number
8
Enter the second number
6
8 is greater than 6
Sample Input and Output 3:
Enter the first number
8
Enter the second number
8
8 is equal to 8
Program Code:
#include<stdio.h>
int main()
{
int f, s;
printf("Enter the first number\n");
scanf("%d", &f);
printf("Enter the second number\n");
scanf("%d", &s);
if(f>s)
printf("%d is greater than %d",f,s);
else if(f<s)
printf("%d is less than %d",f,s);
else
printf("%d is equal to %d",f,s);
return 0;
}
Post A Comment:
0 comments: