Illustrating the Modulus Operator - C Operator

C examples for Operator:Arithmetic Operator

Description

Illustrating the Modulus Operator

Demo Code

#include <stdio.h>

int main (void)
{
    int a = 25, b = 5, c = 10, d = 7;

    printf ("a = %i, d = %i, c = %i, and d = %i\n", a, b, c, d);
    printf ("a %% b = %i\n", a % b);
    printf ("a %% c = %i\n", a % c);
    printf ("a %% d = %i\n", a % d);
    printf ("a / d * d + a %% d = %i\n",
            a / d * d + a % d);//ww w. jav a2s  . c  o  m

    return 0;
}

Result


Related Tutorials