Random numbers are mostly used in games development. The srand () function generate a number between zero to maximum . In this problem we generate 5 random numbers.
Source Code
#include<iostream> #include <ctime> #include <cstdlib> using namespace std; int main () { int a,b,c,d; srand ((unsigned)time (NULL)); a=rand(); cout<<" Generate First Random Number : " <<a <<endl; b=rand(); cout<<" Generate Second Random Number : " <<b<<endl; c=rand(); cout<<" Generate First Random Number : " <<c<<endl; d=rand(); cout<<" Generate First Random Number : " <<d<<endl; }
0 comments:
Post a Comment