Hello pplz..., was just wonderin' if anyone can help me with a problem I am haffing.... I was just tryin' to do a simbple program that asks if you want to fire, and if you do if generates a random number of either 1 or 2. and depending on the generated number, the program will tell the user if missed or not. But heres the problem, I always end up with a hit... why?
srand() should be called once as soon as possible in your code.
As Abramus said, you are declaring another rand_num inside the scope of the if statement, this has the effect of hiding the one in the outer scope (main). When you then do (rand_num == 1) it uses the rand_num from the main scope which has not been changed.