我是一名嘗試使用VS 2012 Ultimate學習C編程的初學者。錯誤:預期「;」
我剛剛學會了如何製作一個「攝氏到華氏」轉換器,所以我決定進一步把它放到「球體積」計算器中。這是我鍵入:
#include <stdio.h>
#include <string.h>
char line[100]; /*Line input by the user*/
char line_2[100]; /*Second line input by the user*/
float radius; /*Value of the radius input by the user*/
float pi; /*Value of the pi input by the user*/
float volume /*Result of the calculation*/
float result_volume; /*Result of the second calculation*/
float result_volume2; /*Result of the third calculation*/
float result_volume3; /*Result of the fourth calculation*/
int main()
{
printf("Please write the value of the radius: ");
fgets(line,sizeof(line),stdin);
sscanf(line,"%f",&radius);
printf("Please write the value of the Pi ");
fgets(line_2,sizeof(line_2),stdin);
sscanf(line_2,"%f",&pi);
volume = radius*radius*radius;
result_volume = volume *pi;
result_volume2 = result_volume*4;
result_volume3 = result_volume2/3;
printf("When the radius is %f, and the Pi, %f, then the volume of the sphere is:
%f\n", radius, pi, result_volume3);
return (0);
}
,當我嘗試編譯此,我不斷收到錯誤:
Error: Expected a ";" on float result_volume.
在哪裏我犯這樣的錯誤,我怎麼能解決這個問題?請幫忙!