Dremendo Tag Line

Input 2 decimal numbers and find the floor value of their sum using mathematical functions in C

Mathematical Functions - Question 4

In this question, we will see how to input 2 decimal numbers and find the floor value of the sum of the numbers in C programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.

Q4) Write a program in C to input 2 decimal numbers and find the floor value of the sum of the numbers.

Program

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

int main()
{
    float a,b,s;
    int x;
    printf("Enter 2 decimal numbers\n");
    scanf("%f%f",&a,&b);
    s=a+b;
    x=floor(s);
    printf("Floor value of sum = %d",x);
    return 0;
}

Output

Enter 2 decimal numbers
12.36
8.47
Floor value of sum = 20
video-poster