Saturday 18 November 2017

C++ Program to Emulate N Dice Roller


Code:

#include    iostream
#include    stdlib.h

using namespace std;

int main(int argc, char **argv)
{
    cout << "Enter the number of dice: ";
    int n;
    cin >> n;
    cout << "The values on dice are: ( ";
    for (int i = 0; i < n; i++)
        cout << (rand() % 6) + 1<<" ";
    cout<<")";
}



Output:

Enter the number of dice: 5
The values on dice are: ( 6 6 5 5 6 )

Enter the number of dice: 1
The values on dice are: ( 6 )

Enter the number of dice: 3
The values on dice are: ( 6 6 5 )


More C++ Programs:














100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...