Check If Tenth Digit is Odd or Even (Using if-else)

The program must accept an integer N as the input. The program must print Odd if the tenth digit is odd. Else the program must print Even as the output.

Example Input/Output 1:
Input:
932

Output:
Odd

Example Input/Output 2:
Input:
143

Output:
Even

#include<stdio.h>
int main()
{
    int N;
    scanf("%d", &N);
    if(((N % 100) / 10) % 2){
        printf("Odd");
    }
    else{
        printf("Even");
    }
    return 0;
}
Previous Article

Matrix Border - Previous & Next

Next Article

Define class Person

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *