ahmed0saber

Rand() in C++

Nov 5th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.17 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     // from 0 to 4
  7.     int a=rand()%5;
  8.     // from 1 to 5
  9.     int b=rand()%5+1;
  10.     cout<<a<<endl<<b;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment