初学C语言——函数介绍(2)
#include <stdio.h>
int sum(int n);
int main(int argc , const char * argv[]){
int s = sum(1000);
printf("sum=%d\n",s);
return 0;
}
int sum(int n){
int s = 0;
for(int i=1;i<=n;i++){
s += i;
}
return s;
}
#include <stdio.h>
int sum(int n);
int main(int argc , const char * argv[]){
int s = sum(1000);
printf("sum=%d\n",s);
return 0;
}
int sum(int n){
int s = 0;
for(int i=1;i<=n;i++){
s += i;
}
return s;
}