# AIQ2 - low = 10; high = 40; r = genran(high, low); fout...

This preview shows page 1. Sign up to view the full content.

#include <iostream> #include <fstream> #include <cstdlib> #include <ctime> using namespace std; int genran(void); int genran(int); int genran(int,int); int main() { ofstream fout("overload.out"); int r, low, high; unsigned seed; cout << "Enter a seed: "; cin >> seed; srand(seed); r = genran(); fout << "A random integer between 1 and 100 is " << r << endl; high = 50; r = genran(high); fout << "A random integer between 1 and " << high << " is " << r << endl;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: low = 10; high = 40; r = genran(high, low); fout &lt;&lt; &quot;A random integer between &quot; &lt;&lt; low &lt;&lt; &quot; and &quot; &lt;&lt; high; fout &lt;&lt; &quot; is &quot; &lt;&lt; r &lt;&lt; endl; system(&quot;notepad overload.out&quot;); return 0; } int genran(void) { int a=1,b=100,r; r = rand() % (b - a + 1) + a; return r; } int genran(int b) { int a=1,r; r = rand() % (b - a + 1) + a; return r; } int genran(int b,int a) { int r; r = rand() % (b - a + 1) + a; return r; }...
View Full Document

## This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Ask a homework question - tutors are online