若运行时输入:2,则以下程序的运行结果是 #include void main(void) {char class; printf("Enter 1 for 1st class post or 2 for 2nd post"); scanf("%c",&class); if (class=='1') printf("1st class postage is 19p"); else printf("2nd class postage is 14p"); 。 ) }
举一反三
- 有如下定义struct person{ char name[9]; int age;}; struct person class[4]={ "Johu",17, "Paul",19, "Mary",18, "Adam",16};根据以上定义,能输出字母M的语句是( )。 A: printf("%c\n",class[3].name); B: printf("%c\n",class[3].name[1]); C: printf("%c\n",class[2].name[1]); D: printf("%c\n",class[2].name[0]);
- 若有以下定义,则能打印出字母M的语句是( )。struct person{ char name[12]; int num;};struct person class[8]={"Linan",20,"zhanghai",18,"Maming",23,"wanghua",25,"chenqi",17};? printf("%c",class[2].name[1]);|printf("%c",class[3].name[1]);|printf("%c",class[2].name[0]);|printf("%c",class[3].name);
- #include "stdio.h"void main(){ char a='1',b='2'; printf("%c",b++); printf("%d\n",b-a);}程序运行后输出的结果是:
- 设有以下定义和程序: #include<iostream.h> class A1 public: void show 1() cout<<" class A 1"<<end1; class A2:public A1 public: void show20 cout<<"class A2"<<end1; ; class A3:protected A2 public: void show3() cout<<"class A 1 "<<end1; ; void main() A: A1 obj1;A2 obj2;A3 obj3;则以下不合语法的调用语句是( B: )。A) obj1.show1(); C: B) obj2.show1(); D: C) obj3.show1(); E: D) obj2.show2();
- 下面程序的结果是( )。 #include<iostream.h> class A int a; public: A: A():a(1) B: void showa()cout<<a; C: ; D: Class Bint a; E: public: F: B():a(2) G: void showa()cout<<a; H: ); I: class C:public A,public Bint a; J: public: K: C():a(3) L: void showa()cout<<a; M: ; N: void main()C c; O: c.showa(); P: A) 1 Q: B) 2 R: C) 3 S: D) 程序有错误