Hi most of all must be knowing how to generate a random number . In this code i have used the rand( ) function so that it will print random numbers from 1 to 10. But if i run it always prints 9 . I think it should print different random numbers isnt it? Am i missing anything here in generating random numbers.
please help me in understanding rand( ) functionCode:#include<stdio.h> #include<stdlib.h> int main() { int j; j=1+(int) (10.0*rand()/(RAND_MAX+1.0)); printf("%d",j); return 0; }
TIA,
~ codomaniac