#include <stdio.h>
#define GA_OF_PA_NEED 267.0
int getSquareFootage(int squareFootage);
double calcestpaint(int squareFootage);
double printEstPaint(double gallonsOfPaint);
int main(void)
{
//Declaration
int squareFootage = 0;
double gallonsOfPaint = 0;
//Statements
getSquareFootage(squareFootage);
gallonsOfPaint = calcestpaint(squareFootage);
gallonsOfPaint = printEstPaint(gallonsOfPaint);
system("PAUSE");
return 0;
}
int getSquareFootage(int squareFootage)
{
printf("Enter the square footage of the surface: ");
scanf("%d", &squareFootage);
return squareFootage;
}
double calcestpaint(int squareFootage)
{
return (double) (squareFootage * GA_OF_PA_NEED);
}
double printEstPaint(double gallonsOfPaint)
{
printf("The estimate paint is: %lf\n",gallonsOfPaint);
return gallonsOfPaint;
}
출력이 gallonsOfPaint를 0.0으로 표시하는 이유는 무엇입니까? 오류가없고 모든 것이 논리적으로 올바른 것 같습니다. calc 함수에서 calculate 문에 문제가있는 것 같습니다.출력이 잘못된 결과를 반환합니다.
흠, 왜냐하면 :'0 * 267 == 0' 당신은 어떤 가치를 기대 했습니까? – amit