hey guys how to use random function in this app and is its header file <cstdlib> ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

hey guys how to use random function in this app and is its header file <cstdlib> ??

one example please !!

31st Aug 2016, 10:29 PM
Asim
Asim - avatar
1 Answer
+ 2
#include <iostream> #include <cstdlib> using namespace std; int main(void) { srand(time(0)); //initialize the seed cout << rand() % 2; //gives 0 or 1 at random return 0; }
31st Aug 2016, 10:53 PM
Zen
Zen - avatar