我是一名尝试使用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.
在哪里我犯这样的错误,我怎么能解决这个问题?请帮忙!