c语言中程序的循环控制(while语句、for语句实现程序循环特定的次数)
1、while语句
#include <stdio.h>
int main(void)
{
int i;
puts("please input an integer!");
printf("i = "); scanf("%d", &i);
while (i-- > 0)
{
putchar('*');
}
return 0;
}
2、for语句
#include <stdio.h>
int main(void)
{
int i,j;
puts("please input an integer!");
printf("j = "); scanf("%d", &j);
for (i = 0; i < j; i++)
putchar('*');
return 0;
}