# Storing Variables that come from a random number generator

• 01-04-2004
cgn38
Storing Variables that come from a random number generator
I am trying to write a program to add, subtract, multiply and divde Fractions. This is just the add part.
User inputs number of problems and number of digits in the numerator and denominator.
My Questions is how do you store the results of the random number generator?

Code:

```/* Program Title: Fractions Add Programmer: Charles Krolick Date: 12/16/2003*/ #include <stdio.h> #include <math.h> #include <system.h> #include <stdlib.h> #include <time.h> struct add1 {int num [10];} addnum; struct add2 {int dem [10];} adddem;         int main(void) {         int a;//digits in numerator         int b;//digits in demoninator         int c;//number of problems         int j;         int LIMIT;         //int p;                 printf("All answers must be reduced to its simplest form.\n");         printf("How many Problems would you like? \n");                 scanf("%i",&c);                                        printf("Maximum digits in the numerator? \n");        //limit a to 3 digits max                 scanf("%i",&a);                                 if (a==2)                 {                         LIMIT=99;                 }                 if (a==3)                 {                         LIMIT=999;                 }                 srand((unsigned)time(NULL));          //need 1 a for every c                 for (j = 0; j < c; j++)                 {                 int i = rand() % LIMIT;                 //printf("The random number is %d\n", i);                 }                         printf("Maximum digits in the denominator? \n");          //limit b to 3 digits                 scanf("%i",&b);                                 if (b==2)                 {                         LIMIT=99;                 }                 if (b==3)                 {        LIMIT=999;                 }                                         srand((unsigned)time(NULL));          //need 1 b for every c                 for (j = 0; j < c; j++)                 {                 int i = rand() % LIMIT;                 printf("The random number is %d\n", i);                 }                                         //                                //  n1  n2  n3  n4...... //  --- --- --- --- //  d1  d2  d3  d4......                                return 0; }```
• 01-04-2004
Prelude
>how do you store the results of the random number generator?
Most people prefer some form of array, but you can use whatever data structure suits you.
• 01-04-2004
cgn38
OK
I forgot to add that to my question. should I use an array or a struct. Thanks for the advise Prelude.