U
Udyant Wig
I was following Steve Summit's C programming notes at
http://www.eskimo.com/~scs/cclass/notes/top.html
and got inspired by the dice-rolling project. I have written a naive
Gaussian distribution program that simulates throwing a specific number
of n-sided dice a given number of times. The output is the expected
bell curve along with the numerical value of each sum's occurences.
For example, the output for 10000 rolls of three six-sided dice is:
3: 51
4: 148
5: 260
6: 454
7: 686
8: 969
9: 1146
10: 1266
11: 1239
12: 1149
13: 1013
14: 713
15: 433
16: 280
17: 152
18: 41
3:
4: =
5: ==
6: ====
7: ======
8: =========
9: ===========
10: ============
11: ============
12: ===========
13: ==========
14: =======
15: ====
16: ==
17: =
18:
Being a novice, I request the readers of this newsgroup to look over the
source to suggest improvements regarding readability, layout, style,
correctness, idioms, etc. I would appreciate it very much.
I have placed the source files on Pastebin at this URL
http://pastebin.com/1PTVJrTN
In case anyone needs the Makefile, this is what I used:
CC = clang
FLAGS = -Wall -Wextra -std=c89 -pedantic
gauss: gauss.o main.o utils.o
$(CC) $(FLAGS) -o gauss gauss.o main.o utils.o
gauss.o: gauss.c
$(CC) $(FLAGS) -c gauss.c
main.o: main.c
$(CC) $(FLAGS) -c main.c
utils.o: utils.c
$(CC) $(FLAGS) -c utils.c
clean:
rm *.o gauss
Thank you.
http://www.eskimo.com/~scs/cclass/notes/top.html
and got inspired by the dice-rolling project. I have written a naive
Gaussian distribution program that simulates throwing a specific number
of n-sided dice a given number of times. The output is the expected
bell curve along with the numerical value of each sum's occurences.
For example, the output for 10000 rolls of three six-sided dice is:
3: 51
4: 148
5: 260
6: 454
7: 686
8: 969
9: 1146
10: 1266
11: 1239
12: 1149
13: 1013
14: 713
15: 433
16: 280
17: 152
18: 41
3:
4: =
5: ==
6: ====
7: ======
8: =========
9: ===========
10: ============
11: ============
12: ===========
13: ==========
14: =======
15: ====
16: ==
17: =
18:
Being a novice, I request the readers of this newsgroup to look over the
source to suggest improvements regarding readability, layout, style,
correctness, idioms, etc. I would appreciate it very much.
I have placed the source files on Pastebin at this URL
http://pastebin.com/1PTVJrTN
In case anyone needs the Makefile, this is what I used:
CC = clang
FLAGS = -Wall -Wextra -std=c89 -pedantic
gauss: gauss.o main.o utils.o
$(CC) $(FLAGS) -o gauss gauss.o main.o utils.o
gauss.o: gauss.c
$(CC) $(FLAGS) -c gauss.c
main.o: main.c
$(CC) $(FLAGS) -c main.c
utils.o: utils.c
$(CC) $(FLAGS) -c utils.c
clean:
rm *.o gauss
Thank you.