编写函数proc(),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通
问题:
编写函数proc(),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+m)
例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float proc(int m)
void main()
int m;
float s;
system ("CLS");
printf("\nPlease enter M: ");
scanf("%d", &m);
s=proc(m);
printf("The result is: %f\n", s);