Created
May 6, 2016 21:44
-
-
Save bzdgn/6dce9d0184acdca2de539f7222ba703b to your computer and use it in GitHub Desktop.
Get The Closest Multiple Of Four Of An Integer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int closestMultipleOfFour(int num); | |
int main() | |
{ | |
for(int i = 0; i < 20; i++) | |
printf("%2d : %2d\n", i, closestMultipleOfFour(i)); | |
return 0; | |
} | |
int closestMultipleOfFour(int num) | |
{ | |
return (num + 3) & ~0x03; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment