Answers for "c++ rand lib"

C++
0

c++ rand

#include <ctime>

int main() {
 srand((unsigned) time(0)); 
 int result = 1 + (rand() % 6); // return a number between 1 and 6
}
Posted by: Guest on March-25-2022
0

c++ rand

#include <cstdlib>

int main() {
  std::cout << "RAND_MAX value is " << RAND_MAX << std::endl;
}
Posted by: Guest on March-25-2022

Browse Popular Code Answers by Language