Hi,
The following only outputs a zero. Not sure why.
cout << "Percent Connected: " << (Ccounter/(totalElements*6))*100 << " %\n\n" << endl;
Ccounter and totalElements are Ints.
Thanks
Printable View
Hi,
The following only outputs a zero. Not sure why.
cout << "Percent Connected: " << (Ccounter/(totalElements*6))*100 << " %\n\n" << endl;
Ccounter and totalElements are Ints.
Thanks
Integer arithmetics rounds everything down to the next smaller int. Try to convert your operands to double before dividing.
Casting one of the ints should do it, then all other ints will be promoted in the calculation.
cout << "Percent Connected: " << ((double)Ccounter/(totalElements*6))*100 << " %\n\n" << endl;