Hmm not sure how to do c. what are the index locations? Gonna skip and do the rest.
This is what I have so far.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void printarray(int rndarray[]);
void oddarray(int rndarray[]);
int countevenary(int rndarray[]);
int sumary(int rndarray[]);
int main()
{
int rndarray[100]; // array
int x; // index
srand(time(NULL)); // initialize random sequencer
for (x = 0; x < 100; x++)
{
rndarray[x] = rand() % 1000;
}
printarray(rndarray);
oddarray(rndarray);
system("pause");
return 0;
}
void printarray(int rndarray[])
{
int x;
int numPrinted = 0;
for (x = 0; x < 100; x++)
{
if ((rndarray[x] % 3 == 0) || (rndarray[x] % 7 == 0))
rndarray[x] = 0 - rndarray[x];
}
printf("The array ten values to a line\n\n");
for (x = 0; x < 100; x++)
{
printf("%3d ", rndarray[x]); // prints 10 numbers to a line
if (numPrinted < 9)
numPrinted++;
else
{
printf("\n");
numPrinted = 0;
}
}
}
void oddarray(int rndarray[])
{
int x;
int numPrinted = 0;
printf("\n\nThe odd values of the array\n\n");
for (x = 0; x < 100; x++)
{
if (rndarray[x] % 2 == 0)
printf("");
else
{
printf("%3d ", rndarray[x]); // prints 10 numbers to a line
if (numPrinted < 9)
numPrinted++;
else
{
printf("\n");
numPrinted = 0;
}
}
}
printf("\n\n");
}