2002-2003学年第二学期c++试卷.docVIP

  • 14
  • 0
  • 约6.8万字
  • 约 6页
  • 2016-12-21 发布于贵州
  • 举报
华东交通大学2002-2003学年第二学期考试卷 C++ 课程 闭卷 必修 班级:   学号: 姓名: . 一、填空题(每空3分,共36分)。 1、在字长为32位的机器中,sizeof(char)= (1) 字节,sizeof(unsigned int)= (2) 字节. 2、C++语法规定,任何变量在使用前必须先 (3) ;变量有两个值,一个是变量本身的值,另一个是变量的 (4) 。 3、C++中任何一个数组的名字是一个 (5) 指针,该指针的值是该数组 (6) 的地址。 4、函数调用时的参数传递主要分为单向传递和 (7) 传递,前者的特点是 (8) 。 5、函数重载时要求同名函数的参数 (9) 或 (10) 不同,否则无法确定是哪个函数。 6、静态数据成员是类的所有对象中 (11) 的成员,静态数据成员初始化与一般数据成员初始化 (12) 。 二、判断题(每小题2分,共16分) 1、在说明语句 int a(15),b=a,*p=a;中,b的值的*P的是相等的。(  ) 2、在不同类型操作数组成的表达式中,其表达式的类型一定是最高类型double型。(  ) 3、break语句也可以用于if体内,它可退出if语句。(  ) 4、在一个被调用函数中,一个return语句可返回多个值给调用函数。(  ) 5、在传值调用中,要求实参和形参的类型完全一致并且个数相等。(  ) 6、for循环中,循环变量的作用域是该循环的循环体内。(  ) 7、类中所提供的成员函数可以直接访问私有成员。(  ) 8、私有继承中,基类中所有成员对派生类的对象都是不可见的。(  ) 三、写出程序的运行结果(每小题4分,共40分) 1、#include iostream.h void main() { int a,b,c,d(5); c=2,c+=10; a =b=10; a * = 2; b / = 2; c % = 2; couta,b,cendl; } 2、#include iostream.h void main() { int a = 50 , b(0) ; b = ++a; couta,bendl; b = a++; couta,bendl; } 3、#include iostream.h void main() { int f = 2002 , x; if( f != 3) x = 2003 ; else x = 20 ; coutf,xendl; } 4、#include iostream.h void main() { int i=1,sum=0; while(i=10) sum+ = ++i; cout sum= sum , i= iendl; } 5、#include iostream.h void main() { int i; for(i=4 ; i=10 ; i++ ) { if (i%3= =0) continue; couti; } } 6、#include iostream.h void main() { char flag=c ; switch(flag) { case a :cout1endl ; case b :cout2endl ; break; case c : cout 3endl ; default : cout 4endl ; break; } } 7、#include iostream.h void main() { static int b[][3] = { {1,2,3},{4},{5,6} }; b[0][2]=12,b[1][2]=18; cout **b\t**(b+1) \t**b+1\t*(*(b+1)+2) \n; cout b[0][2]+b[1][2]+b[2][2] endl; } 8、#include iostream.h void Swap( int a, int b); void main() { int x( 10 ), y( 7 ); coutx=x y=yendl; Swap( x , y ); coutx=x y=yendl; } void Swap(int a, int b)

文档评论(0)

1亿VIP精品文档

相关文档