Learn about C Program to Compute Quotient and Remainder using fmod function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Compute Quotient and Remainder using fmod function
The % operator cannot be used on a floating-point number in a C code. However, if we want to find the remainder on a floating-point number, we should use the fmod() function specified in “math.h,” which accepts two parameters and returns a floating-point value.
Program:
#include<stdio.h>
#include<math.h>
int main()
{
float a, b;
printf("Enter two number: ");
scanf("%f %f", &a, &b);
printf("Product = %.2f\n", a*b);
printf("Remainder = %.2f", fmod(a,b));
return 0;
}
Output:
Enter two number: 30 5
Product = 150.0
Remainder = 0
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Compute Quotient and Remainder
C Program to Compute Addition Subtraction and Multiplication