problems

this is my assignment and below is the my code where am I wrong?....Write a program that simulates the tossing of 3 die and computes the probability of obtaining each of the values 3 to 18. Your program should ask the user how many rolls to simulate, and then perform the simulation and report the results. Include an appropriate srand() function so you get different results each time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  #include "stdafx.h"
#include <iostream>
using namespace std;
#include <cstdlib>
#include <ctime>
#include <iomanip>

int pairofdiceroll();
int main()

//int _tmain(int argc, _TCHAR* argv[])
{
	int rollarray[11]={0};
	int numrolls;
	int i;
	srand(static_cast<unsigned>(time(NULL)));
	cout << " How many roll?";
	cin >> numrolls;
	for (i=0; i,numrolls; i++)
	{
		int theRoll;
		theRoll= pairofdiceroll();
		cout << theRoll << " ";
		rollarray[ theRoll-2]++;
	}
	cout << "\nResults\n";
	for(i=0; i<11; i++)
	{
		cout << showpoint << fixed << setprecision(2);
		cout << setw(10) << rollarray[i] << " " << setw(2) << i+2 << "'s were rolled(" << (static_cast<double>(rollarray[i])/numrolls)*100 << "%)\n";
	}
	return 0;
}
int pairofdiceroll()
{
	int result;
		int d1 = rand()%6+1;
		int d2 = rand()%6+1;
		int d3 = rand()%6+1;
		result = d1+d2+d3;
		return result;
}
Look at your first for statement. The actual argument, in parenthesis... I think you'll be able to spot what's wrong. At least, I'd rather not have to spell it out so plainly.
thanks lol
Topic archived. No new replies allowed.