So I made this coin flipping program. It generates a random number between 1 and 2, and checks to see how many "flips" it would take for it to get 15 flips in a row. However, every time I run it, I get the same number, 13505, every single time! How can I fix this, so that it doesn't do this every time? I tired changing the value of num to 1-100, but it still comes up with the same answer every time(this time its 11341)
#include <iostream>
#include <string>
#include <time.h>
#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;
int main() {
begin:
system("cls");
system("TITLE Coin Flip");
int i=0;
long int j=0;
while(i<15)
{
int num=rand()%2+1;
j++;
if(num==1)
{
i++;
}
else if(num==2)
{
i=0;
}
}
cout<<j<<endl;
system("pause");
}