Hello folks...
I'm working on a program that will generate 100 numbers in range of 1-999 and then there are few things I have to do....
Here is what I have so far and I'm hoping that someone can explain further to me...
a. Print the odd values, ten to a line
b. Return the count of the number of even values
c. Return the location of the smalles value in the array
Now, so far I got program that generates numbers, I have code that will print 10 to a line but I'm stuck on the loop that will check for odd values and print them to line... Please dissregard b and c and help me with a, I'll try to work on the rest...
Thanks a lot,
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 100
int main (void)
{
int number[SIZE];
int i;
int lineCount = 0;
double tmp;
srand(time( NULL ));
for(i =0; i < SIZE; i++)
{
tmp=(double)rand()/((double)RAND_MAX+1);
number[i] = (int)(999*tmp+0.5);
} // Generates numbers in the range 1-999
for(i=0; i < SIZE; i ++)
{
printf(" %d",number[i]);
lineCount++;
if (lineCount > 9)
{
printf("\n\n");
lineCount = 0;
}
} // printArray a. Print the array ten values to a line.
return 0;
}