我用tc编了一个很简单的程序,实在看不出哪里又错了~ 总是有一个declaration syntax error。。
#include<stdio.h>#include<conio.h>floatradius,base,height,side,area;voidprint_menu(vo...
#include<stdio.h>
#include<conio.h>
float radius,base,height,side,area;
void print_menu (void)
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
int main (void) //这里总说我是“declaration syntax error?为什么?”
{
int command;
int running=TRUE;
do
{
print_menu(void)
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
print("\nThanks for using");
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running)
printf("area is %d",area);
return 0;
}
void print_menu (void)
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\quit: 4");
printf("please key in the type:");
}
万分感谢哈! 展开
#include<conio.h>
float radius,base,height,side,area;
void print_menu (void)
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
int main (void) //这里总说我是“declaration syntax error?为什么?”
{
int command;
int running=TRUE;
do
{
print_menu(void)
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
print("\nThanks for using");
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running)
printf("area is %d",area);
return 0;
}
void print_menu (void)
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\quit: 4");
printf("please key in the type:");
}
万分感谢哈! 展开
4个回答
展开全部
楼主太粗心了,不是掉了分号就是掉了f
#include<stdio.h>
#include<conio.h>
float radius,base,height,side,area;
void print_menu ();
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
int main () //这里总说我是“declaration syntax error?为什么?”
{
int command;
int running=TRUE;
do
{
print_menu();
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
printf("\nThanks for using");
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running);
printf("area is %d",area);
return 0;
}
void print_menu ()
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\\quit: 4");
printf("please key in the type:");
}
#include<stdio.h>
#include<conio.h>
float radius,base,height,side,area;
void print_menu ();
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
int main () //这里总说我是“declaration syntax error?为什么?”
{
int command;
int running=TRUE;
do
{
print_menu();
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
printf("\nThanks for using");
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running);
printf("area is %d",area);
return 0;
}
void print_menu ()
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\\quit: 4");
printf("please key in the type:");
}
追问
能不能标出来?谢啦。。只找到了一个啊。。囧。。。
追答
void print_menu (); 掉了分号
do while后面掉了分号
一个函数中printf 掉了 f
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
#include<conio.h>
float radius,base,height,side,area;
void print_menu (void); //1
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
void main(){ //2
int command;
int running=TRUE;
do
{
print_menu(); //3
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
printf("\nThanks for using"); //4
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running);
printf("area is %d",area);
// return 0; //5
}
void print_menu (void)
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\quit: 4");
printf("please key in the type:");
}
VC下通过, 而且我标出来额 ,,都是小毛病。
#include<conio.h>
float radius,base,height,side,area;
void print_menu (void); //1
#define CIRCLE 1
#define TRIANGLE 2
#define SQUARE 3
#define QUIT 4
#define TRUE 1
#define FALSE 0
void main(){ //2
int command;
int running=TRUE;
do
{
print_menu(); //3
scanf("%d",&command);
if(command==1)
{
printf("\nplease key in the radius:");
scanf("%d",&radius);
area=3,14159*radius*radius;
}
else if(command==2)
{
printf("\nplease key in the base and the height:");
scanf("%d%d",&base,&height);
area=0.5*base*height;
}
else if(command==3)
{
printf("\nplease key in the side:");
scanf("%d",&side);
area=side*side;
}
else if(command==4)
{
printf("\nThanks for using"); //4
running=FALSE;
}
else
{
printf("\nPlease key in the tyoe again:");
}
}while(running);
printf("area is %d",area);
// return 0; //5
}
void print_menu (void)
{
printf("\ncircle: 1");
printf("\ntriangle: 2");
printf("\nquare: 3");
printf("\quit: 4");
printf("please key in the type:");
}
VC下通过, 而且我标出来额 ,,都是小毛病。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用do
{
}
while();这种结构应该在while();后面加分号的,只单用while()才不用加的。
{
}
while();这种结构应该在while();后面加分号的,只单用while()才不用加的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你应该把int main (void) 写成void main()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询