第五章 循环结构程序设计:5.1 用while和do-while语句实现循环5.2 for语句和循环的嵌套5.3 for语句的应用5.4 break语句的应用5.5 continue语句的应用5.1用while和do-while语句实现循环:5.1 用while和do-while语句实现循环
5.2for语句和循环的嵌套:for语句和循环的嵌套
5.3for语句的应用:for语句的应用
5.4break语句的应用:break语句的应用
5.5continue语句的应用:continue语句的应用
5.6循环结构程序设计例题讲解(1):循环结构程序设计例题讲解(1)
5.7循环结构程序设计例题讲解(2):循环结构程序设计例题讲解(2)
[单选题]#include <stdio.h>

main( )
{ int x=0,y=5,z=3;
while(z-->0&&++x<5) y=y-1;
printf(“%d,%d,%d”,x,y,z);

程序执行后的输出结果是

选项:[3,2,0, 5,-2,-5, 3,2,-1, 4,3,-1]
[单选题]下述for循环语句________
int i,k;
for (i=0,k=-1;k=1;i++,k++)  printf(“***”);

选项:[是无限循环, 一次也不循环, 判断循环语句结束的条件非法, 只循环一次]
[单选题]有以下程序

#include <stdio.h>

main()

{int s;

scanf("%d",&s);

while(s>0)

{ switch(s)

{ case 1:printf("%d",s+5);

 case 2:printf("%d",s+4); break;

 case 3:printf("%d",s+3);

 default:printf("%d",s+1);break;

}

scanf("%d",&s);

}

}

  运行时,若输入1 2 3 4 5 0<回车>,则输出结果是


选项:[66666 , 666656 , 6566456
, 66656]
[单选题]有以下程序

#include <stdio.h> 

main( )
{ int i,s=0;
 for(i=1;i<10;i+=2) s+=i+1;
 printf(“%d”,s);

程序执行后的输出结果是

选项:[自然数1~9中的奇数之和, 自然数1~10中的偶数之和, 自然数1~10的累加和, 自然数1~9的累加和]
[单选题]以下程序执行后的输出结果是

#include <stdio.h>

main( )
{ int i,n=0;
for(i=2;i<5;i++)
{ do
    { if(i%3) continue;
       n++;}
  while(!i);
  n++;}
printf(“n=%d”,n);

选项:[n=3, n=5, n=2, n=4]
[单选题]下面的程序 的结果是:

#include <stdio.h>

main()

{ int x=3;

do

   {printf("%d",x-=2);}

while(!(--x));

}


选项:[输出的是1 , 输出的是3和0  , 输出的是1和-2, 是死循环]
[单选题]下述程序的输出结果

#include<stdio.h>

main()

{  int y=10;

   while(y--);

   printf(“y=%d”,y);


选项:[y=0, y=随机值, y=1, y=-1]
[单选题]下述for语句

int i,x;

for (i=0,x=1;i<=9&&x!=876;i++)

 scanf(%d”,&x);


选项:[无限循环, 最多循环10次, 一次也不循环, 最多循环9次]
[单选题]以下程序运行后的输出结果是
#include <stdio.h>

main()
{   int c=0,k;
 for(k=1;k<3;k++)
    switch(k)
    { default:c+=k;
      case 2:c++;break;
      case 4:c+=2;break; }
 printf("%d",c);

}

选项:[5, 7, 9, 3]
[单选题]以下程序的运行结果是
 #include <stdio.h>
 main()
 { int x=8;
   for( ; x>0; x--)
       { if(x%3)   { printf(“%d,”,x--);

                        continue; }
         printf(“%d,”,--x); } 

}


选项:[8,7,5,2, 8,5,4,2, 7,4,2, 9,7,6,4]
[单选题]以下程序运行后的输出结果是

#include<stdio.h>

main()

{ int a=1,b=2;

  for(;a<8;a++) { b+=a;a+=2;}

  printf(“%d,%d”,a,b);

}



选项:[7,11, 8,11, 9,18, 10,14]
[单选题]程序运行后的输出结果是

#include<stdio.h>

main()

{ int i,j,m=2;

   for(i=1;i<3;i++)

  {for(j=3;j>0;j--) 

           {if(i+j>3) break;

            m*=i*j;} }

   printf(“m=%d”,m);}


选项:[m=5, m=6, m=4, m=2]

温馨提示支付 ¥1.00 元后可查看付费内容,请先翻页预览!
点赞(0) dxwkbang
返回
顶部