Hi the aim of my program is to allow a user to enter the size of an array and then allows the user to enter the values into an array. The bit im having a problem with is I want to count how many odd and even numbers there are in the array. I then want to print out the odd and even numbers. I've had a go but its not working-I was hoping that someone could look at the code and see where Im going wrong or if you've got another way to do it please reply.
# include <stdio.h>
# define MAX 100
int main(void)
{
int oddcount, evencount;
int array[MAX],i,n;
printf("\n Enter Array Size: ",MAX);
scanf("%d", &n); // User enters Array Size
for(i = 0; i < n; i++)
{
printf("\n Enter %d value: ",i+1);
scanf("\n %d", &array[i]); // Allows user to enter values into the Array
}
putchar('\n');
printf("\nArray Values: ");
for(i = 0; i < n; i++)
{
printf("%3d ",array[i]); //Prints out the array
}
//**************************************//
{
for (i = 0; i < n; i++); // This section of the code is meant to determine
// whether the values in the array are odd or even.
oddcount = 0;
evencount = 0;
if (i%2 != 0)
{
printf("\nThe number %d Is Odd.\n", i);
oddcount++;
}
else
{
printf("\nThe number %d Is Even.\n",i);
evencount++;
getch();
return 0;
}
}
Thanks
TrueCoding