Random Number using c
/*this is the program like ludo
we use time because time always change
we divide by 7 bcoz remminder is always less than 7
we also know dice has maximum 6
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int number;
srand(time(NULL));
number = rand()%7;
printf("rolling result %d " , number);
return 0;
}
**★*********★**********★*******
winning game program using random number
/*let assume player play with entry fees
250 and win between 100 to 500
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int number;
int upper = 500, lower = 100;
srand(time(NULL));
number = rand() % (upper -lower+1) + lower;
printf ("congratulations\n");
printf("you have WON %d rupees " , number);
return 0;
}
Comments
Post a Comment