declaration syntax error (C语言) 急!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/24 18:52:38
int mul (int a,int b);
main()
{
int a,b,c;
a=5;
b=10;
c=mul (a,b);
printf("multiplication of %d and %d is %d",a,b,c);
}
int mul (intx,int y)
int p;
{
p=x*y;
return(p);
}

#include <stdio.h>

int mul (int a,int b);
int main() {
int a,b,c;
a=5;
b=10;
c=mul (a,b);
printf("multiplication of %d and %d is %d",a,b,c);
}
int mul (int x,int y) {
int p;
p=x*y;
return p;
}

你的局部变量p的声明应该放在函数体里面,就是说应该在大括号里面

而不是函数头和大括号之间

mul函数里p定义没有放进函数体的括号内
还有参数表第一项INT X之间应有空格