第一篇:while、for、do-while循环语句求1到10的累乘求积
输出:3628800 for:
#include “stdio.h” main(){ long acc=1;
int n;
for(n=1;n<=10;n++)
{acc=acc*n;}
printf(“%ld”,acc);
getch();}
while:
#include “stdio.h” main(){ long acc=1;
int n=1;
while(n<=10)
{
acc=acc*n;
n++;
}
printf(“%ld”,acc);
getch();}
do-while #include “stdio.h” main(){ long acc=1;
int n=1;
do
{acc=acc*n;
n++;}
while(n<=10);
printf(“%ld”,acc);
getch();}