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 <iostream>
#include <conio.h>
#include <cmath>

using namespace std;

int main()
{
    float a;
    int x;
    cout<<"Enter a decimal number ";
    cin>>a;
    x=ceil(a);
    if(x%2==0)
    {
        cout<<"Even Number";
    }
    else
    {
        cout<<"Not Even Number";
    }
    return 0;
}

Output

Enter a decimal number 12.3
Not Even Number
video-poster