C++ Syntax (Toggle Plain Text)
#include #include using namespace std; int main() { int random_integer = rand(); cout << random_integer << endl; }C++ Syntax (Toggle Plain Text)
#include #include using namespace std; int main() { cout << "The value of RAND_MAX is " << RAND_MAX << endl; }C++ Syntax (Toggle Plain Text)
#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int random_integer = rand(); cout << random_integer << endl; }C++ Syntax (Toggle Plain Text)
#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int random_integer; for(int index=0; index<20; index++){ random_integer = (rand()%10)+1; cout << random_integer << endl; } }C++ Syntax (Toggle Plain Text)
#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int random_integer; int lowest=1, highest=10; int range=(highest-lowest)+1; for(int index=0; index<20; index++){ random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); cout << random_integer << endl; } }
No comments:
Post a Comment
Thank you