% & fmod() : reminder after division

We will get reminder of a division by using % operator .
x % y 
x = division numerator number
y = division denominator number

Example with integer as inputs

#include <stdio.h>
#include <math.h>
int main(void){
     long int    x,y , z;
     x=13;
     y=3;
     z  = (x % y);
     printf("%d ", z);
     return 0;
}
The above code will give this output.
1

Example with float variables by using fmod()

#include <stdio.h>
#include <math.h>
int main(void){
     float    x,y , z;
     x=13.345;
     y=2.32;
     z  = fmod(x, y);
     printf("%f ", z);
     return 0;
}
Output is here
1.745001
Your Rating




Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer