C++ Programming

 

10 Pseudo-random numbers

Program to generate 10 Pseudo-random numbers using rand() function


Source Code

 

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>
// this program generates ten pseudo-random numbers
// using C++'s rand() function

int main()
{
const int NUMBERS = 10;

float randvalue;
int i;

srand(time(NULL));
for (i = 1; i <= NUMBERS; i++)
{
randvalue = rand();
cout << setw(20) << randvalue << endl;
}

return 0;
}
 

 


DISCLAIMER

Paked and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.  (Disclaimer)

 

 

Home     Disclaimer     Advertise      Contact us     

Copyright © 2006-08 Paked.com. All rights reserved.

Note: Site best viewed at 1024 x 768 or higher screen resolution

 

footer image footer image