Close
To suscribe Cquery.h please enter your email below..
After suscribing kindly check your mail box immediately
to complete your suscription.
I don't want any update | Let me download
Cquery.h
Code less C fast..
Download v0.1
Cquery.h is written by a student of SSUET by keeping TURBOC compiler in his mind only.
All the code are copyrighted so please respect other's efforts :) and don't distribute Cquery.h with your name.
Thanks.

Friday, 4 April 2014

rand_range(initial boundary,final boundary)

rand_range takes two integer numbers as arguments, then return a random integer number between them.
Remember if you pass 5 and 7 as a range then boundaries are also included as rand_range(5,7) may return 5 or 7 and 6.

Syntax:

rand_range(initial boundary[integer] ,final boundary[integer]);

Example:


#include<cquery.h>
void main(void)
{
int i;
randomize();
for(i = 0 ; i < 10 ; i++)
{
printf("Random number between 10 and 20 %d\n",rand_range(10,20));
}
getch();
}

Remember final boundary should be greater than initial boundary otherwise it will throw an error as.
#include<cquery.h>
void main(void)
{
int i;
randomize();
printf("Random number between 10 and 20 %d\n",rand_range(40,20));
// Output: 
// final boundary should be greater than initial boundary in rand_range error:0
getch();
}

No comments:

Post a Comment