AIQ3 - high = 50; r = genran(high); fout << "A...

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

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> #include <cstdlib> #include <ctime> using namespace std; int genran(int a=100,int b=1) { int r; r = rand() % (b - a + 1) + a; return r; } int main() { ofstream fout("default.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;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: high = 50; r = genran(high); fout << "A random integer between 1 and " << high << " is " << r << endl; low = 10; high = 40; r = genran(high, low); fout << "A random integer between " << low << " and " << high; fout << " is " << r << endl; system("notepad overload.out"); return 0; }...
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