我不明白我出錯的地方。它不會在第二個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 –