-5

How to generate any random number of any width in C?? Like, to generate a number of width 3 it should be between 100 to 999. So how to code this?

CODER
  • 11
  • 3

2 Answers2

0

You can use rand() function. I hope with this can help you Random Number

huzain07
  • 1,051
  • 2
  • 8
  • 17
0

You can use rand() function . It returns value between 0 to RAND_MAX.

To get a random number between a range you can write like this -

  int r;
  r= rand()%901+100;

This will give a random number between 100 and 1000.

ameyCU
  • 16,489
  • 2
  • 26
  • 41