gpt4 book ai didi

c-不能打印成本

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

<分区>

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

int main()
{
float L=0; //L is litre
float gallon;
gallon = 3.785*L;
char input;
float cost;

printf("Hello, welcome to PetrolUpHere!!\n");
printf("Would u like unleaded or diesel fuel?");
scanf("%c", &input);
printf("Enter the litre you want to fuel:");
scanf("%f", &L);

switch (input) {
case 'u' :
cost = 1.98*gallon;
printf("The cost is :%f ",&cost);
break;

case 'd' :
cost = 1.29*gallon;
printf("The cost is :%f ",&cost);
break;
}

getch();
return 0;
}

程序无法显示成本结果,仅在我完成输入 scanf 语句和 L 值后显示成本 = 0.0000。我是 c 程序的新手,希望能得到帮助。谢谢

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