Reputation: 27
#include <stdio.h>
#include <math.h>
int main()
{
float n,f;
printf("n too:");
scanf("%f",&n);
f=sqrt(n);
f=n%f;
printf("%f",f);
return(0);
}
It iss my code. But i get this "Invalid operands to binary (have float and float)" error in 9th line.
How to solve this ?
Upvotes: 0
Views: 1175
Reputation: 106012
Operands of %
must be of integer type. You should use the library function fmod
.
Synopsis
#include <math.h> double fmod(double x, double y); float fmodf(float x, float y); long double fmodl(long double x, long double y);
Description
The
fmod
functions compute the floating-point remainder ofx/y
.
Upvotes: 4