I made a for loop and I was hoping that it'd make the D variable I put in the paranthesis for ( ) a random number each time
How do I make it so I can get a random variable for the D value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void read_and_total(int acctNum, int dataUsed, int time Used)
{
int D,
P;
for (D =0; D <= 1000; D++)
{
dataUsed = dataUsed + D;
}
{
for (P = 0; P <= 1000; P++)
timeUsed = timeUsed +P;
}
- If you're ok with a pseudo-random number there're rand, srand and random functions in <stdlib.h>
- There are websites that generate genuine random numbers, unfortunately your application needs to access the generator on the website which obviously requires you to be online. Another option is use of a real HW random number generator.