函数原型
代码一
#include<stdio.h>
void sum(int begin, int end)
{int i;int sum = 0;for(i=begin; i<=end; i++){sum = sum +i;}printf("%d到%d的和是%d\n", begin, end, sum);
}int main()
{sum(1,10);sum(20,30);sum(40,50);return 0;
}
代码二(函数原型)
#include<stdio.h>
void sum(int begin, int end);int main()
{sum(1,10);sum(20,30);sum(40,50);return 0;
}void sum(int begin, int end)
{int i;int sum = 0;for(i=begin; i<=end; i++){sum = sum +i;}printf("%d到%d的和是%d\n", begin, end, sum);
}
代码三(原型里可以不写参数名)
#include<stdio.h>
void sum(int , int );
int main()
{sum(1,10);sum(20,30);sum(40,50);return 0;
}void sum(int begin, int end)
{int i;int sum = 0;for(i=begin; i<=end; i++){sum = sum +i;}printf("%d到%d的和是%d\n", begin, end, sum);
}