Advertisement
udaykumar1997

random number generation

Aug 18th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. // re4(8).cpp
  2. /* this program generates a random number from a set of given numbers, 20 times */
  3. #include<iostream>
  4. #include<stdlib.h>
  5. #include<strings.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int numbers[] = { 3, 13, 22, 57, 417 };
  12.     int length = sizeof(numbers);
  13.     for (int aa=1;aa<=20;aa++)
  14.         {cout <<numbers[rand()%length]<< endl;}
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement