Q Quốc Ân New member Sep 21, 2021 #1 What will be the output of the following C++ code? Code: #include <cstdlib> #include <iostream> using namespace std; int main() { int ran = rand(); cout << ran << endl; } A. Any number B. 89 C. 0 to RAND_MAX D. 79
What will be the output of the following C++ code? Code: #include <cstdlib> #include <iostream> using namespace std; int main() { int ran = rand(); cout << ran << endl; } A. Any number B. 89 C. 0 to RAND_MAX D. 79
P Phương Quyên New member Sep 21, 2021 #2 Answer: c Explanation: As the declared number is integer, It will produce the random number from 0 to RAND_MAX. The value of RAND_MAX is library-dependent, but is guaranteed to be at least 32767 on any standard library implementation. Output: Code: $ g++ rand.cpp $ a.out 574 Upvote 0 Downvote
Answer: c Explanation: As the declared number is integer, It will produce the random number from 0 to RAND_MAX. The value of RAND_MAX is library-dependent, but is guaranteed to be at least 32767 on any standard library implementation. Output: Code: $ g++ rand.cpp $ a.out 574