lvalue required as left operand of assignment

前端 未结 2 1251
难免孤独
难免孤独 2021-01-29 16:17

i am trying to make a program which calculates the geometrical average.But i get this error mesage: lvalue required as left operand of assignment


 #include         


        
2条回答
  •  清歌不尽
    2021-01-29 16:39

    It is rather a mathematical problem than a programming problem. If you know that

    average*average = number1*number1+number2*number2

    you must evaluate average first. Solution is

    average = sqrt(number1*number1+number2*number2)

    EDIT1: but geometric mean should be computed as

    average = sqrt(number1 * number2)

    according to http://en.wikipedia.org/wiki/Geometric_mean

提交回复
热议问题