Dremendo Tag Line

Input a decimal number and check ceil value is even or not using mathematical functions in C

Mathematical Functions - Question 3

In this question, we will see how to input a decimal number and check if the ceil value of the number is even or not in C programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.

Q3) Write a program in C to input a decimal number and check if the ceil value of the number is even or not.

Program

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

int main()
{
    float a;
    int x;
    printf("Enter a decimal number ");
    scanf("%f",&a);
    x=ceil(a);
    if(x%2==0)
    {
        printf("Even Number");
    }
    else
    {
        printf("Not Even Number");
    }
    return 0;
}

Output

Enter a decimal number 12.3
Not Even Number
video-poster