C++ code for binary search using random number generator and clock
#include<iostream.h> #include<conio.h> #include<ctime> #include<cstdlib> #include<windows.h> int main() { std::srand(static_cast(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: