1

Here's the idea of the code: The code is required to make a random number then keepon spouting random numbers until it reaches that number, but its always the same. heres the code:

#include <stdio.h>
#include <math.h>

int rdt () {
long long int randomonium;
randomonium=rand();
return randomonium;
}
int main (){
int rd;
int no;

while(1){
rd=rand();
printf("%d\n", rd);
if (rd== rdt()){
    break;

}
}
return 0;




}
  • Does this answer your question? [Why do I always get the same sequence of random numbers with rand()?](https://stackoverflow.com/questions/1108780/why-do-i-always-get-the-same-sequence-of-random-numbers-with-rand) – Karl Knechtel Feb 04 '23 at 10:15

1 Answers1

1

You can put a srand(time(NULL)); just before the while to change the random seed used by rand(). Don't forget to include time.h in the code.