0

How to create random number between 50-60

I want to create random number between 50-60 instead of 1-60 is there anything I can do

9th Nov 2016, 12:50 PM
Prakashmani Awasthi
Prakashmani Awasthi - avatar
1 Answer
+ 2
//You can print the random number(50~60) 100 times #include<iostream> #include<time.h> //used for time SEED #include<stdlib.h> //used for srand, rand using namespace std; int main() { //send the SEED as time values = different everytimes srand((unsigned int)time(NULL)); //print for (int k = 0; k < 100; k++) { //set the integer value 'num' to 50~60 randomly. int num = (rand() % 10) + 50; //print the random value 'num' cout << num << endl; } return 0; }
9th Nov 2016, 1:21 PM
S.J LEE
S.J LEE - avatar