若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 #include<stdio.h> main(){ int a,b,s;s

题目
若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 include main(){ int a,b,s;s

若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 #include<stdio.h> main() { int a,b,s; scanf("%d%d",&a,&b); s=a; if(a<b) s=b; s=s*s; printf("%d\n",s); }

A.1

B.4

C.2

D.9

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

若执行下面程序时,从键盘输入"1,2",则输出是_____。 #include <stdio.h> int main() { int a,b,s; scanf("%d,%d",&a,&b); s=a; if (a<b) s=b; s=s*s; printf("%dn",s); return 0; }


B 当n为9时,此时if语句成立,执行n++后,n为10,因此输出n的值为10,故选择B选项。

第2题:

1、[FZ]若执行下面的程序时从键盘上输入7和4,则输出是______。 main() { int a,b,s; scanf("%d %d",&a,&b); s=a; if(a<b) s=b; s=s*s; printf("%d",s); }

A.7

B.0

C.16

D.49


B 当n为9时,此时if语句成立,执行n++后,n为10,因此输出n的值为10,故选择B选项。

第3题:

执行以下程序时输入1234567,则输出结果是【 】。 includemain(){int a=1,b; scanf("%2

执行以下程序时输入1234567<CR>,则输出结果是【 】。

include <stdio.h>

main()

{ int a=1,b;

scanf("%2d%2d",&a,&b); prinff("%d %dhn",a,b);

}


正确答案:12  34
12  34 解析:本题考查的知识点是:Scanf()函数。 scanf()是标准输入函数;其第1个参数为格式控制字符串。其中“%2d”表示读入一个2个字符宽的整数。所以本题代码将连续读入2个2字符宽的整数分别存到变量a和b中。根据题目要求,输入数据1234567CR>,则scanf()读入的两个整数分别为 12和34,故输出结果为12  34。

第4题:

若执行下面的程序时,从键盘上输入3和4,则输出结果是

main( )

{

int a,b,s;

cin>>a>>b;

s=a;

if(a<B)s=b;

s=s*s;

cout<<s<<endl;

}

A.14

B.16

C.18

D.20


正确答案:B

第5题:

若执行下列的程序时,从键盘上输入1和2,则输出结果是()。 include main() { int a,b,s;

若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。

#include<stdio.h>

main()

{ int a,b,s;

scanf("%d%d",&a,&B) ;

S=a;

if(a<B) s=b;

s=s*s;

printtf("%d\n",s);

}

A.1

B.4

C.2

D.9


正确答案:B
解析:本题考查if语句。scanf函数通过键盘读入 a、b的值,a=1,b=2。第一个if语句,先判断条件,发现ab条件成立,则s=b=2,s=s*s=4。

第6题:

若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。includemain(){ int a,b,s; sc

若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 #include<stdio.h> main() { int a,b,s; scanf("%d%d",&a,&b); s=a; if(a<b) s=b; S=S*S, printf("%d\n",s); }

A.1

B.4

C.2

D.9


正确答案:B
解析:本题考查if语句。scanf函数通过键盘读入a、b的值,a=1,b=2。第一个if语句,先判断条件,发现ab条件成立,则s=b=2, s=s*s=4。

第7题:

若执行下面的程序时,从键盘上输入3和4,则输出结果是main(){ int a,b,s;cin>>a>>b; s=a; if(a<B) s=b: s=s*s;cout<<s<<end1;}

A.14

B.16

C.18

D.20


正确答案:B
解析:按照程序的执行顺序.考生可以很快得出正确答案为B。

第8题:

若执行下列程序时从键盘上输入2,则输出结果是()。 inclUde main() {int a; scanf("%d",

若执行下列程序时从键盘上输入2,则输出结果是( )。

#inclUde<stdio.h>

main()

{int a;

scanf("%d",&A);

if(a++<3)

printf("%d\n",A);

else printf("%d\n",a--);

}

A.1

B.3

C.2

D.4


正确答案:B
解析:本题考查if else语句。程序中首先使用函数scanf()通过键盘读入a的值,并通过第1个if语句,先判断条件,取a的值2和3比较,然后将a的值加1,发现条件成立,执行下列的printf语句,输出a的值3。

第9题:

若执行下列的程序时,从键盘上输入1和2,则输出结果是()。includemain(){int a,b,s; scan

若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 #include<stdio.h> main() { int a,b,s; scanf("%d%d",&a,&b); s=a; if(a<b)s=b; s=s*s; printf("%d\n",s); }

A.1

B.4

C.2

D.9


正确答案:B
解析: 本题考查if语句。scanf函数通过键盘读入a、b的值,a=1,b=2。第一个if语句,先判断条件,发现ab条件成立,则s=b=2,s=s*s=4。