编写程序:输入x和m,用do-while语句求y=x+x*x/2+x*x*x/3+…
时间: 2024-06-06 08:06:52 浏览: 165
C语言程序设计-用do-while语句求1~100的累计和;.c
5星 · 资源好评率100%
do {
printf("请输入x和m:");
scanf("%d%d", &x, &m);
} while (m <= 0);
int i = 1;
double y = x;
double term = x;
do {
y += term;
i++;
term *= x / i;
} while (i <= m);
printf("y=%f", y);
阅读全文