Just wondering.....how does modulo ( % ) work exactly? And if any number % 2 == 0 then the number is even, right? Thanks!
Just wondering.....how does modulo ( % ) work exactly? And if any number % 2 == 0 then the number is even, right? Thanks!
Read this
gg
>how does modulo ( % ) work exactly?
Something like this (except far better optimized):
>And if any number % 2 == 0 then the number is even, right?Code:#include <stdio.h> int main ( void ) { int lhs = 7; int rhs = 3; int result = 0; int rem = lhs; for ( result = 0; rem >= rhs; result++ ) rem -= rhs; printf ( "%d %% %d == %d\n", lhs, rhs, rem ); printf ( "%d %% %d == %d\n", lhs, rhs, lhs % rhs ); return 0; }
That would be a good assumption.
-Prelude
My best code is written with the delete key.