现有如下程序段 #include"stdio.h" main() { int k[30]={12,324,45,6,768,98,21,34,453,456}; int count=0,i=0; while(k[

admin2009-02-15  12

问题 现有如下程序段    #include"stdio.h"    main()    {  int k[30]={12,324,45,6,768,98,21,34,453,456};       int count=0,i=0;       while(k)       {  if(k%2==0||k%5==0)count++;          i++;  }         printf("%d,%d\n",count,i);}    则程序段的输出结果为

选项 A、7,8
B、8,8
C、7,10
D、8,10

答案8

解析 在C语言中,定义一维数组的语句一般形式如下:
   类型名    数组名[常量表达式];
   一维数组的引用形式为:数组名[下标表达式]。 count表示能被2整除或被5整除的个数,i则计算有多少个数组元素。
转载请注明原文地址:https://kaotiyun.com/show/cfXp777K
0

最新回复(0)