by Dinesh Thakur

Program illustrates the application of operator modulus(%) to random numbers generated in order to limit the maximum size of random numbers. This is helpful in sampling problems as well as in playing of dice. In dice play, the maximum value that can be obtained is 6. The code for such a case is illustrated below.


#include <stdio.h>

#include <stdlib.h>
int main()
  int number_to_guess = rand() % 100 + 1;
  printf("Random Number Between 1 and 100 is :%d ",number_to_guess);
  return 0;

Random Number is Chosen Between 1 and 100