+ 6
Hey !! Guys .. please help me to solve this problem in c++ .. please send me its coding ... The question is đđđđđ....
write a program that simulates the rolling dice of two dice. the sum of the two values should then be calculated. use a 1- d array to tally the number of times each possible sum appear print the result in tabular format...
7 Respostas
+ 2
Here's what I coded so far:
#include <iostream>#include<iomanip>using namespace std;int main(){ const int arraysize = 13; int counter[13], sum=0; // init counter for(int i=0; i<13; i++) counter[i] = 0; int die1; int die2; for ( int roll1 = 0; roll1 <=36000; roll1++ ) { die1 = 1 + rand() % 6; die2 = 1 + rand() % 6; counter[die1+die2]++; } cout<<"sum of Faces"<<setw(13)<<"Frequency"<<endl; for(int face=2; face<arraysize;face++) { cout<<setw(7)<<face<<setw(13)<<counter[face]<< endl;
sum += counter[face]; } cout << "sum: " << sum; return 0;}
I think this will help u. thanks
+ 17
If you won't lift a finger to help yourself, you can't expect anyone else to come to your aid. đ
+ 6
ok
+ 5
that's your answer .... đ if you don't know say it properly ... don't give this type of comment on my question ... I am the beginner in c++ ... understand ..
+ 3
opps , sorry , can u please correct it's order.
+ 2
hey, anyone will be my friend...?
- 1
start with learning about rand()