の仲間のプログラマーを使用するまでCを実行しません。私はこの分野にはかなり新しいので、私は自分の問題を抱えているかもしれません。私はquitコマンド
円の面積と円周を見つけるプログラムを書くように言われました。 1つの条件として、出力を小数点以下5桁まで表示します。出力は次のようになります。
円の半径は________です。
円の直径は______です。
円の面積は__です。
周囲は____です。
ここに私はこの問題のために書いたコードです。
#include<stdio.h>
int main()
{
float r, area, circ, diam, pi = 3.14159;
printf("Enter the radius please");
scanf("%f\n", &r);
printf("The radius of the circle is %0.5f\n", r);
diam = 2 * r;
printf("The diameter of the circle is %0.5f\n", diam);
area = pi * r * r;
printf("The area of the circle is %0.5f\n", area);
circ = 2 * pi * r;
printf("The circumference of the circle is %0.5f\n", circ);
return 0;
}
コードが実行され、私はこれを示す端末
Enter the radius please4
でIは、試験試料として4を置きました。これは、プログラムが動作しなくなったときです。私はq
と入力し、Enterキーを押します。これは出力の残りの部分がそうであるように見えるときです。
The radius of the circle is 4.00000
The diameter of the circle is 8.00000
The area of the circle is 50.26544
The circumference of the circle is 25.13272
あなたは4を入力した後に返すヒットしましたか?そうでない場合は、数字を入力し終わったかどうかをプログラムが知る方法はありません。 –