Originally posted by murand
What I really need help with is the count of even numbers....
It's in the for loop.... you just don't see it yet
*hint* add another variable for the even counter.
And I also need to find the location of the smallest number, not the number but physical location in the array....
Any ideas how to do this???Thanks a lot
not too bad... consider the following
Code:
#include <stdio.h>
int main(void)
{
int array[] = { 5, 7, 2, 4, 1, 3, 2 };
int found, i, lowest;
lowest = 999;
for(i=0; i < 7; i++)
{
if(lowest > array[i])
{
lowest = array[i];
found = i;
}
}
for(i=0; i < 7; i++)
printf("array[%d] had %d. \n", i, array[i]);
printf("\narray[%d] had the smallest value -> %d",
found, array[found]);
return EXIT_SUCCESS;
}
There are potential problems such as two or more elements having the same lowest value. If that is the case then you would need to write the appropriate fix.
It's late for me now... 3 am so my brain is 99% zonked. Hopefully that will compile.
HTH