C语言习题(继续)补考的

来源:百度知道 编辑:UC知道 时间:2024/06/07 03:09:14
6.执行下面的程序后,输出为。
void main( )
{
int m=20;
swith(m)
{
case 19: m+=1;
case 20: m+=1;
case 21: m+=1;
case 22: m+=1;
}
printf("%d\\n",m);
}
A.20 B) 21 C) 22 D) 23
7.若有“int a=1,x=1;”,则循环语句“while(a<10) x++; a++;”的循环执行___。
A.无限次 B.不确定次 C.10次 D.9次
8.语句while(!E);中的表达式!E等价于 。
A.E==0 B.E!=1 C.E!=0 D.E==1
9.设i,j,k均为int型变量,执行完下面的for循环后,k的值为 。
for (i=0,j=10;i<=j;i++,j--) k=i+j;
A.10 B.9 C.8 D.7
10.若有以下数组说明,则数值最小的和最大的元素下标分别是____。
int a[12]={1,2,3,4,5,6,7,8,9,10,11,12};
A.1,12 B.0,11 C.1,11 D.0,12
11.若有以下说明,则数值为4的表达式是。
int a[12]={1,2,3,4,5,6,7,8,9,10,11,12};
char c='a’,d,g;
A. a[g-c] B. a[4] C. a[‘d’-‘c’] D. a[‘d’-c]

12.在C语言程序中,有关函数的定义正确的是____。
A. 函数的定义可以嵌套,但函数的调用不可以嵌套
B. 函数的定义不可以嵌套,但函数的调用可以嵌套
C. 函数的定义和函数的调用均不可以嵌套
D. 函数的定义

6--D 因为case语句后没有break;所以case后的都要运算。所以为23
7--D 循环语句while(表达式);当while后面的表达式为假时,循环不执行。当a为10时候停止不执行。

所以只有九次。
8--A
9--A
10--B
11--D
12--B函数的定义不可以嵌套
13--D 内部变量不一定在整个程序运行期间都存在
14--A
15--A
16--C
17--C 多维数组最右一维不能省略
18--D
19--D
#include<stdio.h>

int main()
{
int a, b, num1, num2, temp;
printf("Input a & b:\n");
scanf("%d %d", &num1, &num2);
if (num1 > num2) /*找出两个数中的较大值*/
{
temp = num1;
num1 = num2;
num2 = temp; /*交换两个整数*/
}
a = num1;
b = num2;
while(b) /*采用辗转相除法求最大公约数*/
{
temp = a % b;
a = b;
b = temp;
}
printf("The GCD of %d and %d is: %d\n", num1, num2, a); /*输出最大公约数*/
printf("The LCM of them is: %d\n", num1 * num2 / a); /*输出最小公倍数*/
return 0;
}

6.D 7.D 8.A 9.A 10.B 11.D 12.D 13.D 14.A 15.A 16.C