为什么在调用函数中用了scanf.之后主函数的scanf和printf语句就不执行了?
#include <stdio.h>int main(void)
{
float radius = 0.0f; //The radius of the table
float diameter = 0.0f; //The diameter of the table
float circumference = 0.0f; //The circumference of the table
float area = 0.0f; //The area of the table
float Pi = 3.14159265f;
printf("Input the diameter of the table: ");
scanf("%f", &diameter); //Read the diameter from the keyboard
radius = diameter/2.0f; //Calculate the radius
circumference = 2.0f*Pi*radius; //Calculate the circumference
area = Pi*radius*radius; //Calculate the area
printf("\nThe circumference is %.2f", circumference);
printf("\nThe area is %.2f", area);
return 0;
}
大家好,我最近刚接触C语言学习,请大家帮我看看这段代码有问题吗?为什么我执行这个程序的时候只执行了以下这个语句:
Input the diameter of the table:
而之后的两个printf内的语句就不执行了:
printf("\nThe circumference is %.2f", circumference);
printf("\nThe area is %.2f", area);
请问这是什么原因? 谢谢大家的指点,感激不尽!