Answer to Question #273853 in C++ for Miru

Question #273853

Roll an N-sided die until the sum of the numbers drawn is greater than X (N and X chosen by the user)


1
Expert's answer
2021-12-01T06:40:31-0500
#include <iostream>
using namespace std;
int main()
{
    int N,sum=0, X, b;


    cout << " Enter number of faces for your dice: ";
    cin>>X;
    cout<<"\nChoose the starting value for N: ";
    cin>>b;
    for (N = b; N <= X; N++) 
    {
        cout << N << " ";
		sum=sum+N;
    }
     cout << "\n SUM = : "<<sum << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS