Even / Odd Counting with Loops

This is a discussion on Even / Odd Counting with Loops within the C Programming forums, part of the General Programming Boards category; I can easily figure out how to determine how whether or not a number is even/odd and display that using ...

Even / Odd Counting with Loops

I can easily figure out how to determine how whether or not a number is even/odd and display that using if-else statements. No problem!

But as I attempt to complete the same task using a sentinal loop; let alone count them up in and print out a message stating how many of each were entered; I am screwed! I was wondering if anyone could provide some pointers in the right direction. This is what I have now:

Code:

#include< stdio.h>
int main()
{
int num;
int oddcount, int evencount;
printf("\nThis program will ask you to enter numbers and determine whether they are even or odd. It will also count how many of each you entered.");
oddcount=0;
evencount=0;
while (num!=999)
{
printf("Enter a number: (to stop entering numbers enter 999) ");
scanf("%d",&num);
if (num%2 != 0)
printf("\nThe number %d Is Odd.\n",num);
oddcount++;
else if (num%2 == 0)
printf("\nThe number %d Is Even.\n",num);
evencount++;
return 0;
}

One last thing?

I appreciate the help, those braces are killing me! The only thing is that I can't get it to complile. I was using my flowchart to create the counting statments requried at the end, and I am getting like 10 compiler errors. Does anyone know how to help me this one time? Please!

Code:

#include< stdio.h>
int main()
{
int num;
int oddcount;
int evencount;
printf("\nThis program will ask you to enter numbers and determine whether they are even or odd. It will also count how many of each you entered.\n");
oddcount=0;
evencount=0;
while (num!=999)
{
printf("Enter a number: (to stop entering numbers enter 999) ");
scanf("%d",&num);
if (num%2 != 0)
{
printf("\nThe number %d Is Odd.\n",num);
oddcount++;
}
else
{
printf("\nThe number %d Is Even.\n",num);
evencount++;
}
}
printf("\nThe number of odd numbers entered was %d, oddcount);
printf("\nThe number of even numbers entered was %d, evencount);
return 0;
}