From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/EXAMPLES/modulo.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 reference/C/EXAMPLES/modulo.c (limited to 'reference/C/EXAMPLES/modulo.c') diff --git a/reference/C/EXAMPLES/modulo.c b/reference/C/EXAMPLES/modulo.c new file mode 100644 index 0000000..7d10986 --- /dev/null +++ b/reference/C/EXAMPLES/modulo.c @@ -0,0 +1,24 @@ + +/************************************************************************ + * + * Purpose: Program to demonstrate the '%' operator. + * Author: M J Leslie + * Date: 19-Mar-94 + * + ************************************************************************/ + +#include + +main() +{ + int i,j; + /* The modulo is the remainder of + after an integer division */ + + printf("14 modulo 7 (14%%7) is %i\n", 14%7); /* answer is 0 */ + printf("15 modulo 7 (15%%7) is %i\n", 15%7); /* answer is 1 */ + + i=10; j=6; + + printf("%i modulo %i (%i%%%i) is %i\n",i,j,i,j,i%j); /* answer is 4 */ +} -- cgit v1.2.3-54-g00ecf