C++ Code To Find Random Numbers From 1 To 6
=======================================
Uses
=========
This Programe is Used In Creating Games Like Rolling Dies Where U Need A Random Number Between 1 and 6
Codes:
=========#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
cout<<time(0)<<endl; //time(0) is used to get the current seconds
srand(time(0));
cout << 1+(rand()%6) << endl;
}
No comments:
Post a Comment