by Dinesh Thakur Category: C Programming (Pratical)

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

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.