I write in Windows on DevC ++. Generation of random numbers, everything works correctly except for the range 1000 - 1112, I can not understand the reason. gives values ranging from a thousand to 2200. What is the problem tell me?
#include <stdio.h> #include <stdlib.h> #include <time.h> main() { srand(time(NULL)); for (int i = 1; i <= 5; i++) //1 to 2 { printf("%d\n", 1 + rand() % 2); } for (int i = 1; i <= 5; i++) //1 to 100 { printf("%d\n", 1 + rand() % 100); } for (int i = 1; i <= 5; i++) //0 to 9 { printf("%d\n", 0 + rand() % 9); } for (int i = 1; i <= 5; i++) //1000 to 1112 { printf("%d\n", 1000 + rand() % 1112); } for (int i = 1; i <= 5; i++) //-1 to 1 { printf("%d\n", -1 + rand() % 1); } for (int i = 1; i <= 5; i++) //-3 to 11 { printf("%d\n", -3 + rand() % 11); } system("PAUSE"); }