#include <iostream> using namespace std; int main() { int dice1,dice2,sum,r,a=0,
ID: 3547040 • Letter: #
Question
#include <iostream>
using namespace std;
int main()
{
int dice1,dice2,sum,r,a=0,b=0,c=0,d=0;
int i;
for(i=1;i<=100;i++)
{
dice1=rand()%6+1;
dice2=rand()%6+1;
sum=dice1+dice2;
if (sum==7||sum==11)
a++;
else if(sum==2||sum==3||sum==12)
b++;
else r;
{
start:
int j;
for(j=1;j<=1;j++)
dice1=rand()%6+1;
dice2=rand()%6+1;
if(sum==r)
c++;
else if(sum==7)
d++;
else{
goto start;
}
}
cout << "Number of wins in first roll : " << a;
cout << "Number of loses in first roll : " << b ;
cout << "Number of wins with points : " << c ;
cout << "Number of loses with points :" << d;
}
return 0;
}
this program is not running. FIx it plzzzzzzzzz
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int dice1,dice2,sum,r,a=0,b=0,c=0,d=0;
int i;
for(i=1;i<=100;i++)
{
dice1=rand()%6+1;
dice2=rand()%6+1;
sum=dice1+dice2;
if (sum==7||sum==11)
a++;
else if(sum==2||sum==3||sum==12)
b++;
else
r++;
{
start:
int j;
for(j=1;j<=1;j++)
dice1=rand()%6+1;
dice2=rand()%6+1;
if(sum==r)
c++;
else if(sum==7)
d++;
else{
goto start;
}
}
cout << "Number of wins in first roll : " << a;
cout << "Number of loses in first roll : " << b ;
cout << "Number of wins with points : " << c ;
cout << "Number of loses with points :" << d;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.