c - 需要左值作为赋值的左操作数

标签 c

我正在尝试编写一个计算几何平均值的程序。但是我收到此错误消息:需要左值作为赋值的左操作数

<小时/>
 #include<stdio.h>
 #include<conio.h>

int main() {
    float number1,number2,avarage;
    printf("enter the numbers which you want to calculate geometrical average of them > ");
    scanf("%f %f",&number1,&number2);

    average*average=number1*number1+number2*number2;

    printf("Geometrical avarage is:%f",sayi);

    getch();

    return 0;
}
<小时/>

(我也尝试过“==”运算符,但此时将 0.00 分配给平均值)

谢谢

最佳答案

与其说这是一个编程问题,不如说这是一个数学问题。 如果你知道这一点

平均值*平均值=数字1*数字1+数字2*数字2

您必须首先评估平均值。解决办法是

平均值 = sqrt(number1*number1+number2*number2)

编辑1: 但几何平均值应计算为

平均值 = sqrt(number1 * number2)

根据http://en.wikipedia.org/wiki/Geometric_mean

关于c - 需要左值作为赋值的左操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25869524/

相关文章:

c - JACK 语言的 Lexer 中的段错误

python - arr = [1, 2, 3] 的引用 arr 存储在哪里?

python - 树莓派和 SPI 接口(interface) (Python) : how to transfer data?

c - 全局变量作为 C 中函数调用的参数

c++ - 工作 "within"结构 C/C++

c - Linux shell 上的 I/O 重定向

c - 这个连接函数有什么问题?

c++ - 是否定义了减去两个 NULL 指针的行为?

c - 删除重复值并在其位置添加 0

c - 取消引用的 union 成员字节不相同