Basics of rand() in C++ & its Application.
Basics of rand() The rand() function in C++ generated a random value in the 'int' acceptable values. This can be used in multiple cases that helps optimize our code for a better result . Let us start by learning the basic syntax and how we can manipulate the rand() function to generate a value which we would prefer to see more often. #include<bits/stdc++.h> using namespace std ; int main () { //syntax of rand () function cout<<rand () <<endl ; //max value of rand () function cout<<RAND_MAX<<endl ; //trends with 'int' data type cout<<INT_MAX<<endl ; //controlling rand () values //between 0-9 ( inclusive ) cout<<rand () % 10 <<endl ; //between 0-99 ( inclusive ) cout<<rand () % 100 <<endl ; //generate at max 100 values //each value being at max 10000 cout&l