- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Program to Emulate N Dice Roller
Here is the code to emulate N dice roller. This can be done by generating random number between 1-6.
Algorithm
Begin Declare n Read n For i = 0 to n-1 do Generate sequence with rand() mod 6 + 1 Print the sequence Done End
Example Code
#include <iostream> 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<<" "; }
Output
Enter the number of dice: The values on dice are: 2 5 4 2 6 2 5
- Related Articles
- Maximum number of dots after throwing a dice N times in C++
- C++ Program to Solve N-Queen Problem
- Program to compute Log n in C
- Dice Roll Simulation in C++
- Program to print last N lines in c++
- C++ program to find n valid bracket sequences
- C++ program to find permutation with n peaks
- How VIEWS can be used to emulate CHECK CONSTRAINT?
- How to emulate a do-while loop in Python?
- C++ program to count how many ways two players win or make draw in dice throwing game
- Program to find greater value between a^n and b^n in C++
- C++ Program to Round a Number to n Decimal Places
- C++ Program to compute division upto n decimal places
- Program to find first N Iccanobif Numbers in C++
- Program to print ‘N’ alphabet using the number pattern from 1 to n in C++

Advertisements