유량을 계산하는 프로그램을 만들고 있지만 프로그램이 실행될 때마다 변수에 입력 할 때마다 틀린 대답을 반환합니다. 나는이 웹 사이트 "http://www.flowmeterdirectory.com/flowcalculator.php"에서 유속을 계산하기위한 공식을 얻었는데, 나는 그것을 프로그램의 결과를 확인하기위한 참고 자료로 사용하고 있지만 결코 작동하지 않는다.C 프로그램이 잘못된 결과를 반환합니다.
#include <stdio.h>
#include <math.h>
#include "PI.h"
int flowRateFormula(int,int); //Finally, finds out the flow rate
int square(int);
int square(int x)
{
x=pow(x,2);
return x;
}
int flowRateFormula(int pipeDiameter,int velocity)
{
int integer3=0.25*(PI*square(pipeDiameter)*velocity);
return integer3;
}
int main()
{
int flowRate;
int velocity;
int pipeDiameter;
printf("Enter velocity of liquid(in./s):");
scanf("%d",&velocity);
printf("Velocity=%d in/s.\n",velocity);
printf("Enter pipe diameter(inches):");
scanf("%d",&pipeDiameter);
printf("Pipe Diameter=%d inches.\n",pipeDiameter);
printf("Applying formula for Flow Rate.........\n");
flowRate=flowRateFormula(pipeDiameter,velocity);
printf("Pipe Diameter=%d inches.\n",pipeDiameter);
printf("Velocity of liquid=%d in/s.\n",velocity);
printf("Thus, the flow rate=%d ft/s.\n",flowRate);
return 0;
}
... 디버거에서 던지고 무슨 일이 일어나는가? – Bart
아, 알겠습니다. 다른 질문에는 "숙제"표시가있어서 학교 생활을 알지 못하는 사이에 우리가 당신을 위해 일하게 해줍니다. 좋은 시도 - 작동하지 않았다. :) –
왜, 왜 사람들은'pow (x, 2)'를 사용하여 숫자를 제곱합니까? –