Skip to content

Instantly share code, notes, and snippets.

@ryzokuken
Created October 23, 2016 16:28
Show Gist options
  • Save ryzokuken/8a8aa94bc84c00334c6dc8967f8363b8 to your computer and use it in GitHub Desktop.
Save ryzokuken/8a8aa94bc84c00334c6dc8967f8363b8 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void printArray(int array[], int length) {
int i;
for (i = 0; i < length; i++) {
printf("%d ", array[i]);
}
printf("\n");
}
int main() {
int odd[10], even[10], c_odd = 0, c_even = 0, i;
for (i = 0; i < 10; i++) {
int input;
scanf("%d", &input);
if (input % 2) {
odd[c_odd] = input;
c_odd++;
} else {
even[c_even] = input;
c_even++;
}
}
printf("Printing Odd Array\n");
printArray(odd, c_odd);
printf("Printing Even Array\n");
printArray(even, c_even);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment