//Prompt the user to enter a number
printf("Please enter a number: ");
//Read number
scanf("%d", &number);
//Display number
printf("You entered %d", number);
printf("\n");
//Get a random number and scale to range 3..37
srand(time(NULL));
random_num = (37 - 3) + 1;
//Display random number
printf("Your random number is %d", rand() % random_num + 3);
// Set product to number * random number
product = multiply (number, random_num); //random_num equals 35 ?
How can i store the random value generated for random_num to perform the last multiplication? at the moment the number entered by the user is multiply by 35 :( this generates a random number every time, at the end the number is always multiply by 35. any clue? thank you
Aucun commentaire:
Enregistrer un commentaire