0

Geometric mean

Program is supposed to calculate geometric mean_but there is an error upon compiling n running. https://code.sololearn.com/cUo7zrlE7Ibl/?ref=app

3rd Dec 2020, 11:13 PM
Reynolds Onyango
Reynolds Onyango - avatar
5 Answers
+ 1
Still on line 10. Try to use a floating point number instead of integer for pow() second argument. Integer 1 divided by 3 yields zero. (a * b * c) raised to the power of zero yields 1 pow((a * b * c), 1.0 / n);
4th Dec 2020, 1:37 AM
Ipang
+ 1
Super it works bro. God bless
4th Dec 2020, 7:47 AM
Reynolds Onyango
Reynolds Onyango - avatar
0
Line 10: pow((a " b * c"), 1 / n); <n> is an array (defined at line 9). We can't divide `int` by `int` array unless an index was specified to define which element was desired. (Edit) Mistaken the {} for [] got me thinking was an array.
4th Dec 2020, 12:41 AM
Ipang
0
Int n {3} is not definition of an array. However, I'm wondering why I keep getting the answer 1 every time I run the code even with different values
4th Dec 2020, 12:48 AM
Reynolds Onyango
Reynolds Onyango - avatar
0
Sorry, my sleepy eyes saw the curly brackets {} like square brackets []. I took a closer look and realised it.
4th Dec 2020, 12:55 AM
Ipang