- Messages
- 6,990
- Location
- Toronto, Canada
1. Just because you won't ever use goto doesn't mean you won't use cin. cin is a very powerful input method and is used a lot.
2. That's because the rand() function doesn't actually generate random numbers properly. It has a set sequence that just sort of jumbles the numbers in the range around but is the same every time the application runs.
To debug your code just try this:
You'll see that every time you run the program the random number generated is the same.
2. That's because the rand() function doesn't actually generate random numbers properly. It has a set sequence that just sort of jumbles the numbers in the range around but is the same every time the application runs.
To debug your code just try this:
Code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i = 0;
i = rand() % 11;
printf("%d\n", i);
return 0;
}
You'll see that every time you run the program the random number generated is the same.