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;
}