[Solved] Code blocks, adding and storing integers through a function


Here is a sample program. Enhance as required as suggested in the previous update.

#include <stdio.h>
#include <stdlib.h>
int
main ()
{

  int number, even, odd;
  int *evenarr, *oddarr;
  int evencount = 0, oddcount = 0;
  int i;

  char name;

  evenarr = (int *) malloc(100 * sizeof(int));
  oddarr = (int *) malloc(100 * sizeof(int));

  printf ("Enter numbers within 1-100");
  printf ("Enter 0 to quit");
  do
    {

      scanf ("%d", &number);

      if (number != 0)
        {
          if (number < 1 || number > 100)
            continue;
          if (number % 2 == 1)
            {
              //This is where I don't know how to store the odd numbers
              printf ("odd\n");
              oddarr[oddcount] = number;
              oddcount++;
              /* Realloc the arr if size exceed 100 */
            }
          else
            {

              //And the even numbers here as well
              printf ("even\n");
              evenarr[evencount] = number;
              evencount++;
              /* Realloc the arr if size exceed 100 */
            }
        }
    }
  while (number != 0);

  for(i=0; i<oddcount; i++)
    printf("odd : %d\n", oddarr[i]);
  for(i=0; i<evencount; i++)
    printf("even : %d\n", evenarr[i]);

}

1

solved Code blocks, adding and storing integers through a function