C++ code for binary search using random number generator and clock
#include<iostream> #include<conio.h> #include<cstdlib> #include<ctime> int main() { std::srand(static_cast<unsigned int>(std::time(nullptr))); for (int count=1; count <= 100; ++count) { std::cout << std::rand() << "\t"; // display 5 random numbers per row if (count % 5 == 0) std::cout << "\n"; } return 0; getch(); }
Output: