具有平方根的预期表达

Mad*_*urk 1 c

#define PI = 3.141593
#define G = 6.67259E-11
#define g = 9.80665
#define M = 5.972E+24
#define r = 6378000
#define h = 220

#include <stdio.h>
#include <math.h>
int main(void)
{
    int value;
    value =sqrt((G/M)/(r+h))

    printf("This is the tangential speed:") value;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我对编码很新,我的程序在代码块中给了我几个错误,有人能给我一些指导吗?

Eri*_*hil 5

=从所有#define语句中删除.它们是预处理程序宏定义,而不是赋值语句,并且它们不使用等号.

更改int valuedouble value,使用浮点而不是整数.

添加;value =sqrt((G/M)/(r+h)).C语句通常以分号结尾.

更改printf("This is the tangential speed:") value;printf("This is the tangential speed: %g.\n", value);.printf是一个函数调用,而不是一个语句,所以你在一组括号中传递它所需的一切.字符串是格式字符串; 它包含你想要打印的文字文本和转换规范%g,告诉它将参数转换为字符串.%g告诉它将double参数转换为一般浮点显示形式.