do……while循环
do……while循环学习示例
#include <stdio.h>
main()
{
char ch ;
int num=0;
do {
ch=getchar();
num++;
}while(ch!=’n’);
printf(“%d n”,num-1); /因为其会将回车也当成一个符号计算,所以输出结果为num-1/
}
注意:使用do……while循环时,while后面的;不能忘记写,该语句是一个执行结束。所以要有分号。
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/dowhile/474.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.