gpt4 book ai didi

c - 为什么我的 printf float 不显示? (初学者)

转载 作者:太空宇宙 更新时间:2023-11-04 06:48:43 25 4
gpt4 key购买 nike

<分区>

这是我为我的学校程序编写的代码我的问题是为什么 printf 不会显示它作为 inf 出现的浮点值(我相信它是无穷大?)我知道我以前的值都是 int 的,如果我为什么把 float 放在 ()无论如何帮助表示赞赏

加油

#include <stdio.h>
#include <conio.h>

int main()
{
int c1, c2, c3, parallelCap;
float seriesCap;

printf("please enter the value of the first resistor:");
scanf(" %d", &c1);
printf("please enter the value of the second rstr:");
scanf(" %d", &c2);
printf("please enter the value of the third resistor:");
scanf(" %d", &c3);
parallelCap = c1 + c2 + c3;
seriesCap = (float)1/(1/c1 + 1/c2 + 1/c3);
printf("the parallel capacitance is: %d the series
capacitance is: %f/n ", parallelCap, seriesCap);
getch();
return 0;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com