Dremendo Tag Line

Calculate sum and check last digit even or odd in C

if else - Question 8

In this question, we will see how to input 2 numbers and check if the sum 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.

Q8) Write a program in C to input 2 numbers and check if the sum of their last digit is even or odd.

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    int a,b,s;
    printf("Enter 2 numbers\n");
    scanf("%d%d",&a,&b);
    s=(a%10)+(b%10);
    if(s%2==0)
    {
        printf("Sum of their last digit is even");
    }
    else
    {
        printf("Sum of their last digit is odd");
    }
    return 0;
}

Output

Enter 2 numbers
54
69
Sum of their last digit is odd
video-poster