//
// Danny's dice simulator
// Change the sides of the dice to get
// a random number out of your number
//
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// How many sides does your dice have?
int sides;
cout << "How many sides does your dice have?";
cin >> sides;
// Randomise out of users number
int n;
n = rand() % sides + 1;
// n is the resulting number
cout << "Your random number out of ";
cout << sides;
cout << " is:";
cout << n << endl;
// Press any key to continue
system("PAUSE");
return 0;
}
If your number of sides is less than 42, then your answer is always the number of sides.
If your number of sides is more than 42, then the answer is always 42. Help please! :(
K:\CodeBlocks\Projects\dannys-dice\main.cpp:10: error: expected constructor, destructor, or type conversion before '(' token
Bear in mind I know almost nothing about c++, and error reports make no sense to me XD
I added srand( time(0) ); in between usingnamespace std; and int main;.