C 数学和零结果

标签 c

不确定这里的问题是什么,但我一直得到0的结果。预期结果是0.2222222。我想我必须为我的一个变量分配一个零,但我不知道这是在哪里发生的。任何帮助,将不胜感激。谢谢

#include <stdio.h>
#include <math.h>

int main()
{
    double vs = 10;
    double rs = 100;
    double rl_start = 50;
    double rl_stop = 150;
    double rl_step = 5;

    double i, j;
    double n = rl_start;
    int count;

    do
    {
        j = ((rl_start) + (rl_step * count));
        i = (pow(vs, 2) * j) / pow((rs + j),2);
        printf("%lf", i);
        count++;

    }while(j <= rl_stop);

    return 0;
}

最佳答案

使用前需要初始化count:int count = 0;

关于C 数学和零结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10492652/

相关文章:

c - c中多个范围之间的随机数

c - 试图理解这个 strtok 实现中的代码

C&X11 : how to use graphic contexts

c - printf 输出太频繁

c - 为什么使用不同的 C 库?

c - 我是否需要将\0 分配给 c 中的 malloc 字符串?

c - 如何删除无符号整数中的 2 位数字?

c - 根据复选框更改输入框中的文本 (GTK+)

c - x86-64 中的内存分配

c - 如何在Linux中替换另一个文件中的占位符