C program to generate random numbers in any range

Here is a C program to generate random numbers between any range of two digit numbers –

         int s, a, b, n, ran;

         srand(time(0)); // this is to set the seed to current time so we get different random numbers in each try         

         printf("\nEnter lower limit>>");

         printf("\nEnter upper limit>>");


         printf("\nEnter how many random numbers you need");
         for (s = 1; s <= n; s++) { 
            ran = (rand() % (b - (a + 1))) + a; 
            printf("\nRandom #i>> %d ", num); 

Add a Comment

Your email address will not be published. Required fields are marked *