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

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);

+ 1

Super it works bro. God bless

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.

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

0

Sorry, my sleepy eyes saw the curly brackets {} like square brackets []. I took a closer look and realised it.

Hot today

What is indentations... ?

6 Votes

int num = 2;
int x = 3;
if(num >= 2) {
if(x > 4) { num = 3; }
else { num = 4; }
}
else {x = 1; }

1 Votes

Need solution

0 Votes

About Java McQ

0 Votes

Need solution

0 Votes

YouTube Link Finder

0 Votes