Professional Documents
Culture Documents
Combinations of A Given Number When Dice Are Rolled
Combinations of A Given Number When Dice Are Rolled
Combinations of A Given Number When Dice Are Rolled
/* Program to print and count all combinations of a given number when three dice are rolled The prgramm donot use any formula and can be used for any number of dice s=5 means this program works for number 5. 111 t0 666 means for three dice */ #include<iostream.h> #include<stdio.h> #include<conio.h> void main() { clrscr(); bool f; int count=0,v=0,s=5;
for(int i=111;i<=666;i++) { int t=i; f=true; while(t>0) { int r=t%10; if(r==0) { f=false; break; }
t=t/10; } if(f==true) {
int temp=i; while(temp>0) { int r=temp%10; if(r==s) { printf("%5d",i); count++; break; } temp=temp/10; }
cout<<count;