我对编码非常陌生。我正在上课这个课程,在读完课本后,我仍然有点失落。我真的不得不在谷歌搜索以获得该计划的帮助。编译完成后,我一直在
[Error} expected unqualified-id before '{' token".
这是我的代码:
/* This program is intended to compute the following:
1) Prompt for the input of one edge of a cube
2) Calculate the area for one side of the cube
3) Calculate the surface area of the cube
4) calculate the volume of the cube
5) Display all input and calculated values
*/
#include<stdio.h>
//Below is the program code for the surface area of a cube
int main() {
float side, surfaceArea;
printf("Enter length of any side of cube\n");
scanf("%f", &side);
surfaceArea = 6*side*side;
printf("Total surface area of Cube : %0.4f\n",
surfaceArea);
return 0;
}
//Below is the C program to calculate the volume of a cube
#include <stdio.h>
{
float side, volume;
printf("Enter length of any side of cube\n");
scanf("%f", &side);
volume = side*side*side;
printf("Volume of Cube : %0.4f\n", volume);
return 0;
}
答案 0 :(得分:2)
我可以在上面看到2个不同的程序。 第一个程序是正确的,保存在文件中说&#34; surfaceArea.c&#34;。第二个程序不包含main()函数。所以在#include之后写一行int main() 将此程序保存为volume.c