+ 1

Why in rand(rand()) mistake?

#include <iostream> #include <cstdlib> using namespace std; int main() { for (int x = 1; x <= 10; x++) { cout << rand(rand()) << endl; } }

31st Aug 2018, 5:37 PM
MakarovDs
1 ответ
+ 5
Дмитрий Макаров Rand() function takes no arguments and returns an integer that is a random number between 0 and RAND_MAX. so, Rand() inside function is int which means outer Rand() considers int as argument resulting compiler error...
31st Aug 2018, 5:48 PM
Ketan Lalcheta
Ketan Lalcheta - avatar