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 <stdio.h>
#include <conio.h>
#include <math.h>

int main()
{
    float a,b,r;
    int x;
    printf("Enter 2 decimal numbers\n");
    scanf("%f%f",&a,&b);
    r=fmod(a,b);
    x=ceil(r);
    if(x%2==0)
    {
        printf("Even Number");
    }
    else
    {
        printf("Odd Number");
    }
    return 0;
}

Output

Enter 2 decimal numbers
11.31
7.24
Odd Number
video-poster