How do I find how many integers that equal 5 in an array

Apr 15, 2008 at 11:04pm
I know your probably getting tired of me by now but!
If I roll five dice and want to keep them for a score but only use how ever many fives are in the roll for the score. How would I go about doing this?
Thank you for you help!
Apr 16, 2008 at 6:52am
Did you say that you are storing the dice roll values in an array?
You could do this:

1
2
3
int count=0, score=0;
for (i=0;i<5;i++) if theArray[i]==5 count++;
score=count*5;
Apr 17, 2008 at 10:21am
@katielynnsdad
>> You should figure out how to count them without code, how to make algorithms, then write some code, otherwise you can not solve any problem by yourself. just try to do such a tasks by yourself. I am sure You can make it by yourself


Apr 17, 2008 at 10:04pm
I appreciate all the help but I got it figured out. Thanks again!
Topic archived. No new replies allowed.