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.
Remember final boundary should be greater than initial boundary otherwise it will throw an error as.
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