Thread: Code...
View Single Post
Old 11-10-2005, 06:35 PM   #7 (permalink)
mgoldb2
TSF Enthusiast
 
Join Date: Dec 2004
Posts: 604
OS: windows xp


//language: C++
//Random number generator. Will generate as many numbers as needed between min value enter and max value enter including min and max.

Code:
#include<iostream>
#include <ctime>
#include<cstdlib>

using namespace std;

int main()
{
	int max;
	int min;
	int rolls;
	int roll;
	int count;
	char z='y';

	while(z=='y')
	{	
		cout<<"enter number of rolls"<<endl<<endl;
		cin>>rolls;
		srand(time(0));

		cout<<"enter min roll"<<endl<<endl;
		cin>>min;
		cout<<"enter max roll"<<endl<<endl;
		cin>>max;
		cout<<endl<<endl;
	
		max=max-min+1;
		count=1;
			
		while(rolls>0)
		{
			roll=(rand() % max) + min;
			cout<<"roll number "<<count<<":   "<<roll<<endl;
			roll=0;
			rolls--;
			count++;
		
		}

	cout<<endl<<endl<<"do you want to roll again(type y or n)"<<endl;
	cin>>z;
	
	}
	return 1;

}
__________________
mgoldb2 is offline   Reply With Quote