Custom Search

 

 

 

 
 

 

10 Pseudo-random numbers


Binary Search | Bubble Sort | Selection Sort | Finding Maximum Value | Linear Search | Celsius to Fahrenheit | 10 Pseudo-random numbers | Calculating Average | Swapping Values | Lowercase/ Uppercase

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

C++ 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;
}

 

Copyrights

Gary Bronson. "A First Book of C++: From Here to There " Thomson Learning.

                        

 

 

 

Custom Search
 

Home      Disclaimer      Advertise      Contact      Privacy Policy     

Copyright 2004-15 Paked.com. All rights reserved.

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