问题
单项选择题
下面程序的输出结果是( )。
#include<iostream>
using namespace std;
void main()
int a,b;
for(a=1,b=l;a<=100;a++)
if(b>=10) break;
if(b%3= =1)
b+=3;continue;
cout<<a;
A.101
B.6
C.5
D.4
答案
参考答案:D
解析: 该题是对 for 循环语句、条件语句、中断语句的综合考察。循环 for 语句执行了4次,当执行第4次循环的时候b=10退出循环,输出a的值为4。