Skip to content

Instantly share code, notes, and snippets.

@jmkim
Last active June 11, 2016 12:53
Show Gist options
  • Save jmkim/7f3b5aceacd08fc6e2a2170986d10ec2 to your computer and use it in GitHub Desktop.
Save jmkim/7f3b5aceacd08fc6e2a2170986d10ec2 to your computer and use it in GitHub Desktop.
int i;
int var[] = { 1, 3, 2, 4, 6, 5 };
int * varptr = var;
int odd = 0, nonodd = 0;
for(i = 0; i < sizeof(var) / sizeof(int); ++i)
(*(varptr + i) % 2 == 0) ? nonodd += *(varptr + i) : odd += *(varptr + i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment