Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- #define SIZE 7
- int main(void)
- {
- int face;
- int a;
- int roll;
- int frequency[SIZE]={0};
- srand(time(NULL));
- for(roll=1;roll<=20;roll++){
- if(rand()%6==0){
- face=6;
- ++frequency[face];
- }
- else{
- face=rand()%6;
- ++frequency[face];
- }
- }
- printf("%s%17s%18s\n","Face","Frequency","Histogram");
- for(face=1;face<SIZE; face++){
- printf("%4d%17d ",face,frequency[face]);
- for(a=1;a<=frequency[face];a++){
- printf("%c",'*');
- }
- printf("\n");
- }
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement