我不明白我出错的地方。它不会在第二个scanf()
只读跳到下一行。程序不会在第二个scanf()读取()
#include <stdio.h>
#define PI 3.14
int main()
{
int y='y', choice,radius;
char read_y;
float area, circum;
do_again:
printf("Enter the radius for the circle to calculate area and circumfrence \n");
scanf("%d",&radius);
area = (float)radius*(float)radius*PI;
circum = 2*(float)radius*PI;
printf("The radius of the circle is %d for which the area is %8.4f and circumfrence is %8.4f \n", radius, area, circum);
printf("Please enter 'y' if you want to do another calculation\n");
scanf ("%c",&read_y);
choice=read_y;
if (choice==y)
goto do_again;
else
printf("good bye");
return 0;
}
边注:请不要使用goto的 –
'转到do_again;'我们在二十一世纪! ! – NINCOMPOOP
为什么我不应该使用goto –