hi,this is sandy patel.
i need simeone's help as soon as possible.
i discribe my problem as under:

Problem Statement:
This problem requires you to generate a series of random numbers.
There are many algorithms that have been developed for this purpose. One scheme generates
pseudorandom numbers by performing a calculation. The algorithm has been adapted to suit
this assignment. The method begins with an odd 4-digit integer, which is referred to as the
seed number. The seed is multiplied by the value (102 – 3). Using the lowest 4 digits of the
result (the residue) produces a new seed. Continuing this procedure produces a series of 4-
digit random numbers, with each new number used as the seed for the next number.
The following steps describe the algorithm.
Step 1: Enter an odd 4-digit integer seed number that is not divisible by 2 or 5.
Step 2: Multiply the seed number by 97.
Step 3: Extract the lower 4 digits of the result produced by step 2.
This is the procedure for Step 3.
3a: Divide the number by 104
3b: Keep the integer part of the result of step 3a.
3c: Multiply the result, in 3b, by 104.
3d: Subtract this result from the number produced by step 2.
Use this random number as the new seed.
Step 4: Repeat Steps 2 and 3 to generate as many random numbers as required.
Write a program that tests the effectiveness of this algorithm.
To do this we will generate a large number of pseudorandom integers, record them and
investigate the randomness of the numbers produced.
However, the algorithm above will produce numbers up to 9999. To check the randomness of
the output we would like to record the number of times each integer was generated but with
10000 numbers this would be a tedious process. Our task is to make a quick check possible
within the limits of our resources. The quickest way to present the results is on the screen but
it would be impractical to present all 10000 integers. To overcome this we will limit the test
to random numbers between 0 and 9. These can then be easily tabulated on the screen.
Your task then is to generate a large number (maximum 1000) of pseudorandom integers
between 0 and 9. You will use the algorithm above to generate the 4 digit pseudorandom
numbers and from each extract one of the 4 digits to produce a random number of 0-9.
Start by initialising 10 variables, used as counters, to zero. The counters will keep a sum of
the occurrence of each random digit generated. Print out the number of 0s, 1s, 2s etc. that
occurred and the percentage of time they occurred.

i have to make this type of table:

randomnumber count
0 22 or something.
1 ...
2 ...
3 ....

now,i don't know how do get the count from random number and as per my assigenment condition i can't use rand(0),srand(seed);
bye.

>>Extract the lower 4 digits of the result produced by step 2.

The easy way is to convert the number to a string then only use the last 4 digits.

``````int num = 12347;
char buf[10];
sprintf(buf,"%d",num);
int seed = atoi( &buf[1] );``````

>>Extract the lower 4 digits of the result produced by step 2.

The easy way is to convert the number to a string then only use the last 4 digits.

``````int num = 12347;
char buf[10];
sprintf(buf,"%d",num);
int seed = atoi( &buf[1] );``````

The easier way is to divide by 10000 and take the remainder

``int seed = num % 10000 ;``

The easier way is to divide by 10000 and take the remainder

``int seed = num % 10000 ;``

OMG Yes that is a lot easier :*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.