Dice Roller Problem

Im not sure what is wrong with this. its suppose to give 7 random numbers of a dice roll.

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <cstdlib>
#include <iostream>
using namespace std;
 
 int countEm(int testVal,int side1,int side2,int side3,int side4, int side5, int side6, int side7);//porototype the sides of the dice 1-6

 int main()
 {
 int side1;
 int side2;
 int side3;
 int side4; 
 int side5; 
 int side6; 
 int side7;  
   
 srand(time(NULL));
 int counter=0;
 int testVal;
  
 testVal= rand()%6+1;//gives numbers form 1-6
 cout<<testVal;//output random numbers
 
 system("PAUSE");
 
 }                   
  void roll(int testVal,int side1,int side2,int side3,int side4, int side5, int side6, int side7)
 {
  side1=rand()%6+1;  
  side2=rand()%6+1;
  side3=rand()%6+1;
  side4=rand()%6+1;
  side5=rand()%6+1;
  side6=rand()%6+1;
  side7=rand()%6+1;
  
  cout<<"there are"<<testVal<< "1"<<endl;
 }
 int countEm(int testVal,int side1,int side2,int side3,int side4, int side5, int side6, int side7)
 {

 int sum=0;
 
 if(testVal==side1)
 sum++;
  if
 (testVal==side2)
 sum++;
  if
 (testVal==side3)
 sum++;
  if
 (testVal==side4)
 sum++;
  if
 (testVal==side5)
 sum++;
  if
 (testVal==side6)
 sum++; 
 if 
 (testVal==side7)
 sum++;
 
 return sum;
        
}
I only see you getting one random number, testVal. You never seem to call any of your functions.
How would i correct that?
You might want to try calling your functions.
Do you mean like:

cout<<side1<<"repeats"<<testVal<<endl;
Last edited on
Topic archived. No new replies allowed.