若有以下程序段,其中s、a、b、c均已定义为整型变量,且a、c均已赋值(c大于0)s = a;for ( b = 1; b <= c; b++ ) s = s + 1;
A. s=a+b;
B. s=a+c;
C. s=s+c;
D. s=b+c;
查看答案
下面程序执行后的输出结果是( )。#include int main() {int i = 0, s = 0;for (;; ) {if ( i == 3 || i == 5 )continue;if ( i == 6 )break;i++;s += i;};printf( "%d", s );return 0;}
A. 10
B. 13
C. 21
D. 死循环
下面程序执行后的输出结果是( )。#include int main(){ int a = 0, i; for ( i = 1; i < 5; i++ ) switch ( i ) { case 0: case 3: a += 2; case 1: case 2: a += 3; default: a += 5; } printf( "%d", a ); return(0);}
A. 10
B. 13
C. 31
D. 死循环
若有定义:float w; int a,b;则合法的switch语句是( )。
A. switch (w) { case 1.0:printf("*\n"); case 2.0:printf("**\n");}
B. switch (a); { case 1:printf("*\n"); case 2:printf("**\n");}
C. switch (b) { case 1:printf("*\n"); default:printf("\n"); case 1+2:printf("**\n");}
D. switch (a+b); { case 1:printf("*\n"); case 2:printf("**\n"); default:printf("\n");}
执行下面语句后,s=____。int i=1,s=0;while(i++)if(!(i%3))break;elses+=i;printf("%d",s);