rng game

my program produces same number even with rand(). first 5 times running it it does 4 2 3 1 4 no matter what if i rerun program it wont get new numbers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <cstdlib>
using namespace std;
int main() 
{ 
  int m = 0; // number for after get legendary decrease chance
  int n = 5; //number for rng 
  int y = 1 ; //number for turns  negative = more
  cout << "press enter to try for legendary "; //prompt user to play
  while (y < 6) { //also number of turns positive = more
    int x = (1 + (rand() % n)); // generates random number/makes it more difficult
    cout << "\n" << x; //sees which number it generates
    if (cin.get() == '\n') //checks to see if win
      if (x == 4){
        cout << "you got the legendary weapon";
        int m = 1;}
      else {
        cout << "Try again!";
        int m = 0;}
      y += 1;
  if(m = 1)
    
    int n = n + 100;
  }
}
You didn't create a seed. Use srand(time(NULL));
Topic archived. No new replies allowed.