On your own, with your own code, I will give you 3,000 points if you do this for
ID: 3556327 • Letter: O
Question
On your own, with your own code, I will give you 3,000 points if you do this for me.
I want you to develop three different ways to generate random numbers with three different sets of codes, whether it's with arrays, or cases, or however you want. I would like three different random number generators. I will post this question twice, post your answer to both questions, and if i find your code the most suitable, I will give you 1500 points per. Also an explanation along with screenshots would be greatly appreciated. Thank you in advance.
Explanation / Answer
1st method
#include <stdio.h>
#include <stdlib.h>
int main() {
int c, n;
printf("Ten random numbers in [1,100] ");
for (c = 1; c <= 10; c++) {
n = rand()%100 + 1;
printf("%d ", n);
}
return 0;
}
2nd method
#include <stdio.h>
#include <sys/timeb.h>
int main(int argc, char* argv[])
{
struct _timeb tstruct;
_ftime( &tstruct );
printf( "random number: %u ", tstruct.millitm % 100);
return 0;
}
3rd method arrays usage
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define COMPUTATIONS 100
main ()
{int i;
srand(time(NULL));
for (i=0 ; i < COMPUTATIONS ; i++)
{
printf ("random_number[%d]= %d ",i, rand ());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.