为什么我的代码不起作用,cykinder 的体积?

问题描述 投票:0回答:1

请有人帮我修复:圆柱体的体积,但我不断收到错误:

#include <stdio.h>

int main()
{
    const float pi = 3.14;
    float r, h, vol;

    printf("Enter Radius Of the Cylinder.\n");
    scanf("%f", &r);

    printf("Enter Height of the Cylinder.\n");
    scanf("%f", h);

    vol = r * r * pi * h;

    printf("Volume Of Cylinder is %f", vol);
     
    return  0;
}

请有人帮我解决!

c# c coding-style stack-overflow fix-protocol
1个回答
0
投票

你没有在

h
中传递
scanf("%f", h)
的地址的bug。用这个代替:

    scanf("%f", &h);
© www.soinside.com 2019 - 2024. All rights reserved.