Random Number Loop to Array

I really struggle with arrays and I have found out I needed an array to retrieve the values the program prints out. I've looked at tutorials and examples but I still can't get my head around them and don't look similar enough to my scenario. I have already had help from Keene to get the main purpose of the program working but to get the biggest and smallest values returned from the random number loop I'll need an array :(

I'll also probably need a function but I don't exactly know how to integrate my loops into an array. I would like to get a basic idea of how to get it into an array which I could (hopefully) work out myself how to get the big/smallest numbers etc. from the array.

Here is the program so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <time.h>
/* Author hotchoc26 */

int main()
{
system("cls");
srand(time(0));
printf("Welcome! Press any key to begin.");
getchar();

int pos=0;

for (int max = 100, week = 1; pos <=100; max+=5, week++) 
{
	pos=1+(rand() % max);
	printf("\nWeek %d: %1d", week, pos);			
}

printf("\n");
system("pause");
return 0;
}


I would like to know if the following are possible with arrays/functions:

Is it possible to retrieve statistics from the numbers for the 'weeks'? Can I get, for example, the:
First number,
Lowest number of all numbers,
Biggest difference between any two consecutive numbers where the second is smaller/bigger than the first, from First number to Last number, which also shows these numbers,
Total number of numbers returned in the 1-100 range, 1-40 and 1-10 ranges,
Total number of occurances where two consecutive numbers are identical, where a value 100 is returned, or if three in a row return 100 * 2, four is *3 etc.,
Total number of occurances showing the value '1'. If true print 50, two occurances is 150, three is 300, 1,000, 1,500, 3,000, 10,000. If 7 or more, print 10,000.

Hopefully an easy 'total score' which adds up the numbers!

Here's basically how the game works I am trying to make a program of:

http://www.ukmix.org/forums/viewtopic.php?f=21&t=104927
Last edited on
Anyone?
Topic archived. No new replies allowed.