C语言练习题.docx_第1页
C语言练习题.docx_第2页
C语言练习题.docx_第3页
C语言练习题.docx_第4页
C语言练习题.docx_第5页
已阅读5页,还剩20页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 C语言中的标示符只能由字母,数字和下划线三种字符组成,且第一个字符(C)A. 必须为字母B. 必须为下划线C. 必须为字母或下划线D. 可以是字母,数字和下划线中任一字符2、 以下程序的输出结果是(B)void main()int i, j, x = 0;for(i = 0; i 2; i+)x+;for(j = 0; j 3; j+)if(j % 2)continue;x+;x+;printf(“x = %dn”, x);A. x = 4B. x = 8C. x = 6D. x = 123、 有以下程序void main()int a10 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, *p = &a3, *q = p + 2;printf(“%dn”, *p + *q);程序运行后的输出结果是(B)A. 16 B. 10 C. 8 D. 64、 对于下面的程序,说法正确的是(D)void main() int x = 3, y = 4, z = 2; if(x = y + z)printf(x = y + z); else printf(x != y + z); A. 不能通过编译 B. 输出6 C. 输出x != y + z D. 输出x = y + z5、 以下能对二维数组a进行正确初始化的语句是(B) A. int a2= 1, 0, 1, 5, 2, 3; B. int a3= 1, 2, 3, 4, 5, 6; C. int a24= 1, 2, 3, 4, 5, 6; D. int a= 1, 0, 1, , 1, 1;6、 下面程序的执行结果是(A) #define SUM(X) X * X void main() int a = 6;int i = 1, j = 2; a += SUM(i + j)/ SUM(i + j); printf(%dn, a); A. 15 B. 2 C. 7 D. 0 7、 以下程序的运行结果是(B)void main()int a, b;b = (a = 3 * 5, a * 4, a * 5);printf(“%d”, b);A. 60 B. 75 C. 65 D.无确定值8、 执行下列程序时输入:123456789输出结果是(D)void main()char s100;int c, i;scanf(“%c”, &c);scanf(“%d”, &i);scanf(“%s”, &s);printf(“%c, %d, %sn”, c, i, s);A. 123,456,789B. 1,456,789C. 1,23,456,789D. 1,23,4569填空(下方为自加1、自减1操作)#include stdio.hvoid main()int a = 10, b = 15, c;c = -a + +b - a- - b- + a - b - -b + a+;printf(“C = %d”, c);运行结果C = -13 10.#include “stdio.h”void main()int a = 10;int b = a 2;printf(“B = %d”, b);运行结果 B = 40 选择题:1. 下面代码运行后,s 的值是(B)。int s = 0; for (int i = 1; i 10) break; if (i % 2 = 0) s += i; A. 20B. 12C. 10D. 62. 若打印如下图案,画线处应填入(B)。* * * * * * * * * * * * * for (int i = 1; i = 5; i+) for (int j =_; j = 5; j+) Console.Write(*); Console.WriteLine();A. 1B. i C. i + 1D. 03. 下面代码实现数组array的冒泡排序,画线处应填入(D)。 int array = 30, 55, 40, 48 ;int temp;for (int i = 0; i 3; i+) for (int j = 0; j _; j+) if (aj =1) i-;则循环语句执行后,i的值为( A )。A.0 B.1 C.-1 D.42. 有以下程序:main() int i,s=0;for(i=1;i5) printf(“%dn”,m);elseprintf(“%dn”,m-);A.4B.5C.6D.77. 一个C语言程序是由( A )。A.函数组成B.一个主程序和若干子程序组成C. 若干过程组成。D.若干子程序组成。8. 当a=1,b=3,c=5,d=4 ,执行完下面一段程序后x 的值是( A )。if(ab) if(cd) x=1; else if(ac) if(bb&+a=kB)-k+C)k%int(f)D)k=f=m2有以下程序以下是引用片段:main() inta,b,d=25; a=d/10%9; b=a&(-1); printf(%d,%dn,a,b); 程序运行后的输出结果是A)6,1B)2,1C)6,0D)2,03有以下程序以下是引用片段:main() inti=1,j=2,k=3; if(i+=1&(+j=3|k+=3) printf(%d%d%dn,i,j,k); 程序运行后的输出结果是A)1 2 3B)2 3 4C)2 2 3D)2 3 34 若x和y代表整型数,以下表达式中不能正确表示数学关系|x-y|10的是A) abs(x-y)-10& x-y10C) (x-y)10D) (x-y)*(x-y)a)|(m=a printf(%d,%dn,k,m); 程序运行后的输出结果是A) 0,0B) 0,1C) 1,0D) 1,16 阅读以下程序:以下是引用片段:main() intx; scanf(“%d”,&x); if(x-=y)&(y=z)B(x=y)AND(y=z)C)(x=y=z)D)(x=y)&(y=z)二题. 填空1.10化成二进制形式为_2.一个int型数据在内存中占_个字节,一个float型数据在内存中占_个字节答案:一 1.C 2.B 3.D 4.C 5.C 6. B 7.C 8.A二 1. 1010 2. 4 41. 下面的代码编译后会出现什么问题public class MyClass public static void main(String arguments) amethod(arguments);public void amethod(String arguments) System.out.println(arguments);System.out.println(arguments1);a)错误,不能静态引用amethod方法b)错误,main方法不正确c)错误,数组必须包含参数d)Amethod必须声明为String类型2. 下面的代码在输入下面的命令行后会输出什么内容命令行:java myprog good morning代码:public class myprogpublic static void main(String argv)System.out.println(argv2);a) myprogb) goodc) morningd) Exception raised: java.lang.ArrayIndexOutOfBoundsException: 23. 试图编译运行下面的代码会发生什么情况public class MyClassstatic int i;public static void main(String argv)System.out.println(i);a)错误,变量i没有被初始化b) nullc) 1d) 04. 试图编译运行下面的代码会发生什么情况public class Q public static void main(String argv)int anar=new int1,2,3;System.out.println(anar1);a) 1b) Error anar 被引用前没有初始化c) 2d) Error: 数组大小没有定义5. 试图编译运行下面的代码会发生什么情况public class Q public static void main(String argv)int anar=new int5;System.out.println(anar0);a) Error: anar is referenced before it is initializedb) nullc) 0d) 56. 试图编译运行下面的代码会发生什么情况abstract class MineBase abstract void amethod();static int i;public class Mine extends MineBase public static void main(String argv)int ar=new int5;for(i=0;i ar.length;i+)System.out.println(ari);a) 5个0的序列会被输出b) Error: ar 在使用前要初始化c) Error Mine 必须被声明为 abstractd) Error 数组越界7. 试图编译运行下面的代码会输出什么样的结果int i=1;switch (i) case 0:System.out.println(zero);break;case 1:System.out.println(one);case 2:System.out.println(two);default:System.out.println(default);a) oneb) one, defaultc) one, two, defaultd) default8. 试图编译运行下面的代码会输出什么样的结果int i=9;switch (i) default:System.out.println(default);case 0:System.out.print

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论