main()
{ int a,b,sum; printf("input a and b "); scanf("%d%d",&a,&b); sum=add(a,b); printf("sum=%d+%d=%d\n,",a,b,sum);
}
add(x,y)
int x,y;
{ renturn(x+y);
}
函数须先声明后使用,
#include<stdio.h>
void main()
{ int a,b,sum; printf("input a and b \n"); scanf("%d%d",&a,&b);
int add(int a,int b); sum=add(a,b); printf("sum=%d+%d=%d\n",a,b,sum);
} int add(int x,int y)
{ return(x+y);
}
这样在试试。
我知道了
main()
{ int a,b,sum; printf("input a and b :"); scanf("%d%d",&a,&b); sum=add(a,b); printf("sum=%d+%d=%d\n",a,b,sum);
}
add(x,y)
int x,y;
{ return(x+y);
}
int main(void)
{ int a = 0; int b = 0; printf("Enter two numbers a and b: "); scanf("%d%d", &a, &b); printf("%d + %d = %d\n", a, b, add(a,b)); return 0;
}
int add(int x, int y)
{ return x+y;
}