CS110_04a_rand.c - case 2: d2++; break; case 3: d3++;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
rand() function Demo #include<stdlib.h> #include<stdio.h> main () { int i, rolls, face; int d1, d2, d3, d4, d5, d6; d1=d2=d3=d4=d5=d6=0; printf(“Enter number of rolls: “); scanf(“ %d”, &rolls); for (i=1; i<=rolls; i++) { face= 1 + (rand() % 6); switch (die) { case 1: d1++; break;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: case 2: d2++; break; case 3: d3++; break; case 4: d4++; break; case 5: d5++; break; case 6: d6++; break; default: printf(\nHUH?\n); break; } } /* add more code, plus printfs that print out the number of times we chose each number */ }...
View Full Document

Ask a homework question - tutors are online