Skip to content

Instantly share code, notes, and snippets.

@Ryan-Amaral
Created September 12, 2019 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryan-Amaral/fea8b43755207bff03d8622d15c753b4 to your computer and use it in GitHub Desktop.
Save Ryan-Amaral/fea8b43755207bff03d8622d15c753b4 to your computer and use it in GitHub Desktop.
Generate a bunch of random numbers to print to std out.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//https://www.programmingsimplified.com/c-program-generate-random-numbers
int main(){
int numbers = 9001; // number of numbers to print
printf("Printing %d numbers!", numbers);
srand(time(0)); // seed the generator
int i,n;
// print the numbers
for(i = 0; i < numbers; ++i){
n = (rand() % 100);
printf("%d\n", n);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment