I'm trying to write a program that will compare the sum of 2 throws of dice (one throw comprised of 5 dice, the other comprised of 6) so far I'm at the stage where I am trying to make a function to compute the sum for throwing 6 dice but am having a nightmare trying to get my function dice_sum() to work correctly...it just assigns to 'a' the value 0, when I am asking it to add to a the value of array[i] (where i is a position in the for-loop)
I far from competent at programming and suspect I have made mistakes where I think my code is correct. Can someone take a look at the code below and throw me some hints as to why I'm not getting what I'm expecting?
using namespace std;
int dice_Sum(int array);
//this function will take a random number and convert it to a number from one to six based on its remainder modulo 60.
//Need to define this function better perhaps using switch but it seems to work ok for now.
double Random = (rand())%60;
int a = 0;
if (Random >=0 && Random <=9)
a = 1;
if (Random >=10 && Random <=19)
a = 2;
if (Random >=20 && Random <=29)
a = 3;
if (Random >=30 && Random <=39)
a = 4;
if (Random >=40 && Random <=49)
a = 5;
if (Random >=50 && Random <=59)
a = 6;
//This function fills each element of an array of length 6 with a number from 1 to 6 as determined by the random_one_To_Six() function.
int length = 5;
for(int i=0;i <= length; i++)
array[i] = random_One_To_Six();
// I now want to send this array to a function that adds together all the elements within my array and return its sum.
cout << dice_Sum(array);
int dice_Sum(int array)
for(int i=0; i <=5; i++)
a: array[i]+a;//this bit isn't working...I want it to add up the elements from array to array
cout << "**" << a << "**" << endl; // this bit is to check what 'a' is when I change things and figure out what is up.