Dremendo Tag Line

Input 2 decimal numbers and check ceil value of the remainder is even or odd using mathematical functions in C++

Mathematical Functions - Question 5

In this question, we will see how to input two decimal numbers and check if the ceil value of their remainder is even or odd in C++ programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.

Q5) Write a program in C++ to input two decimal numbers and check if the ceil value of their remainder is even or odd.

Program

#include <iostream>
#include <conio.h>
#include <cmath>

using namespace std;

int main()
{
    float a,b,r;
    int x;
    cout<<"Enter 2 decimal numbers\n";
    cin>>a>>b;
    r=fmod(a,b);
    x=ceil(r);
    if(x%2==0)
    {
        cout<<"Even Number";
    }
    else
    {
        cout<<"Odd Number";
    }
    return 0;
}

Output

Enter 2 decimal numbers
11.31
7.24
Odd Number
video-poster