c语言自定义函数怎么带参数

c语言自定义函数怎么带参数厉c语言的自定义函数怎么让他带上参数 参数在住函数中如何使用

举个栗子,比如计算a+b的值的函数

#include<stdio.h>
int plus(int a,int b)
{
int c = a+b;//2.此处定义的c无法被主函数直接调用,因为c为局部变量
return c;//3.要返回计算结果,只能用return语句
}
int main()
{
int i=5,j=7;
int ans = plus(i,j);//1.该过程中,首先将i,j作为参数(与上面的plus函数说明(m,n)一一对应)传递给plus函数。
printf("%d",ans);
}

温馨提示:答案为网友推荐,仅供参考