我是C的新手。我想編寫一個程序來計算Hypotenuse,但是當我運行它時,我得到了垃圾值,我不知道如何處理它。我怎麼處理垃圾?
double Hypotenuse(double base, double perpendicular)
{
double hyp = sqrt((base*base) + (perpendicular*perpendicular));
return hyp;
}
int _tmain(void)
{
double b, p;
printf("Enter the lenght of base\n");
scanf_s("%f",&b);
printf("Enter the lenght of perpendicular\n");
scanf_s("%f",&p);
printf("The hypotenuse of the triangle is %3.3f",Hypotenuse(b,p));
return 0;
}
使用' 「%LF」''爲 – BLUEPIXY
double' @BLUEPIXY爲什麼會這樣?你的意思是在scanf?我在看printf。 –
喜歡你的標題 – bolov