C语言函数调用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/luoganttcc/article/details/88617316
#include <stdio.h>

int sum(int m,int n)
    {
      int i ,sum=0;
      for (i=m;i<=n;i++)
          {
            sum=sum+i;
          }
      return sum;
    }


int main()
    {

     int begin=5,end=99;
     int result=sum(begin,end);
     printf("The sum from %d to %d is %d \n",begin,end,result);

     return result;
    }

The sum from 5 to 99 is 4940 

猜你喜欢

转载自blog.csdn.net/luoganttcc/article/details/88617316