Is there a simple way when using the rand() function to limit it to lets say between 0 and 100?
Is there a simple way when using the rand() function to limit it to lets say between 0 and 100?
-PreludeCode:#include <stdio.h> #include <stdlib.h> int main(void) { int number; number = rand() % 100; printf("Random number 0 - 100: %d", number); return EXIT_SUCCESS; }
My best code is written with the delete key.
Just what I was looking for
You would have to do rand() % 101 for it to be 0-100, because if a number is some multiple of 100 then it would be modulis 0, not 100.