Write a C program to read two integer values and print true if both the numbers end with the same digit, otherwise print false.
Example: If 698 and 768 are given, program should print true as they both end with 8.
At the time of execution, the program should print the message on the console as:
Enter two integer values :
For example, if the user gives the input as 25 53:
Enter two integer values : 25 53
then the program should print the result as:
false
Note: Do use the printf() function with a newline character (\n).
Answers
Answered by
2
Here we have to print 'True' if the last digts of entered two integers are equal and 'False' if last digits are not equal.
So, The steps followed here is:
1) We get two integer as input from the user.
2)Get the last digts from both the integers entered which we get by finding the remainder when divided by 10.
3) Checking if last digits of the both the integers are equal.
4) If equal printing 'True' or else printing 'False'
PROGRAM :
#include<stdio.h>
int main()
{
int a,b;
printf('Enter two integers: ');
scanf('%d %d' a,b);
if(a%10==b%10)
{
printf('True')
}
else
{
printf('False')
}
return 0;
}
Hope this helps :)
Similar questions