Skip to content

Instantly share code, notes, and snippets.

@bzdgn
Created May 6, 2016 21:44
Show Gist options
  • Save bzdgn/6dce9d0184acdca2de539f7222ba703b to your computer and use it in GitHub Desktop.
Save bzdgn/6dce9d0184acdca2de539f7222ba703b to your computer and use it in GitHub Desktop.
Get The Closest Multiple Of Four Of An Integer
#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