If you want different seeds everytime you could use the current time. So you would do something like this:
#include <time.h>
srand(unsigned(time(NULL)));
Then you will get different numbers...
Type: Posts; User: LlamaDolittle
If you want different seeds everytime you could use the current time. So you would do something like this:
#include <time.h>
srand(unsigned(time(NULL)));
Then you will get different numbers...
If you want different seeds everytime you could use the current time. So you would do something like this:
#include <time.h>
srand(unsigned(time(NULL)));
Then you will get different numbers...
You need to include the string header file. So right after #include <iostream> put #include <string>
It sounds like you got your >> and << mixed up. Like cout>> instead of cout<<.
This should do it:
for(int i = 2; i < 10000; i++)
{
bool prime = true;
for(int j = 2; j < i; j++)
{
if(i%j == 0)
prime = false;
You declared your strings incorrectly. Instead of string name1[10],name2[10], use string name1,name2.
With the string class name[10] refers to the 10th element of the string. It doesn't create a...
You can use the rand() function in cstdlib to get a random number.
It is used like this:
int x = rand() % 5; //x would be between 0 and 4
Before calling rand(), you should call srand()...
You can use the rand() function in cstdlib to get a random number.
It is used like this:
int x = rand() % 5; //x would be between 0 and 4
Before calling rand(), you should call srand()...