【发布时间】:2016-03-05 04:15:46
【问题描述】:
我试图在两个循环中输出相同数量的 printf 语句,我必须使用 for 和 while 。不幸的是,我的第二个循环出现了无限循环。我在第二个循环中做错了什么?
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS
int main()
{
int x,c,v,b;
printf("Please enter a number between 1 and 25 \n");
scanf_s("%d",&x,&c);
for (x != 0; x--;)
{
printf("I'd rather be doing something else \n");
}
while (c!=0 ) {
printf("Programming is easy");
c--;
}
}
【问题讨论】:
标签: c loops for-loop while-loop