Calculate product and check last digit even or odd in C
if else - Question 9
In this question, we will see how to input 3 numbers and check if the product of their last digit is even or odd in C programming using the if else statement. To know more about if else statement click on the if else statement lesson.
Q9) Write a program in C to input 3 numbers and check if the product of their last digit is even or odd.
Program
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b,c,s;
printf("Enter 3 numbers\n");
scanf("%d%d%d",&a,&b,&c);
s=(a%10)*(b%10)*(c%10);
if(s%2==0)
{
printf("Product of their last digit is even");
}
else
{
printf("Product of their last digit is odd");
}
return 0;
}
Output
Enter 3 numbers 18 32 46 Product of their last digit is even