Write a program that uses the srand() and time() function to print on the screen a truly random number from 1 trough 20 generated by the rand() function.
#include <iostream>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
using namespace std;
int main(){
srand (time(NULL));
for(int i=0;i<13;i++){
int number= rand() % 20 + 1;
cout<<number<<"\n";
}
system("pause");
return 0;
}
Comments
Leave a comment