写出程序的运行结果。 #include
第1题:
有以下程序 main() {int a=0,b=0; a=10; /* 给a赋值 b=20; 给b赋值 */ printf("a+b=%d\n",a+b);/* 输出计算结果 */ } 程序运行后的输出结果是______。
A.a+b=10
B.a+b=30
C.30
D.出错
第2题:
有以下程序
#include <stdio.h>
main( )
{ printf("%d\n",NULL); }
程序运行后的输出结果是
A.0
B.1
C.-1
D.NULL没定义,出错
第3题:
有以下程序: #include<stdio.h> main() { printf("%d\n",NULL);} 程序运行后的输出结果是( )。
A.0
B.1
C.-1
D.NULL没定义,出错
第4题:
有以下程序 #include<stdio.h> #define PT3.5; #define S(x)PT*x*x; main() { inta=1,b2; printf("%4.1f\n",S(a+b); } 程序运行后的输出结果是______。
A.14.0
B.31.5
C.7.5
D.程序有错无输出结果
第5题:
有以下程序 #include<stdio.h> void main() { int a=1,b=0; printf("%d,",b=(a++)+(a++)); pfintf("%d\n",a+B); } 程序运行后的输出结果是( )。
A.4,6
B.2,5
C.3,5
D.2,6
第6题:
有以下程序
#include <staio.h>
main( )
{ int a;
scanf(”%d”,&a);
if(a++<9)printf(”%d\n”,a);
else printf(”%d\n”,a--);
}
程序运行时从键盘输入9<回车>,则输出结果是
A)10
B)11
C)9
D)8
第7题:
有以下程序: #include<stdio.h> main( ) { int a; scanf("%d",&a); if(a++<9)printf("%d\n",a); clsc printf("%d\n",a--); } 程序运行时从键盘输入9<回车>,则输出结果是( )。
A.10
B.11
C.9
D.8
第8题:
阅读程序: main( ) {int x; scanf("%d',& x); if (x- -<5)printf("%d\n",x); else printf("%d\、n",x+ +); } 程序运行后,如果从键盘上输入5,则输出结果是 ( )
A.3
B.4
C.5
D.6
第9题:
阅读下面语句,则程序的执行结果是______。
include"stdio.h"
main()
{ inta=-1,b=1,k;
if((++a<0)&&! (b--<=0))
printf("%d,%d\n",a,b);
else printf("%d,%d\n",b,a);}
第10题:
以下程序运行后的输出结果是()。 main( ) {int a=010,b=2,c; c=a+b; printf(“%d”,c); }
第11题:
第12题:
0,0
1,0
3,2
1,2
第13题:
以下程序的输出结果是( )。 #include <stdio.h> main() { int a=21,b=11; printf("%d\n",--a+b,--b+a); }
A.30
B.31
C.32
D.33
第14题:
若运行输入:3<回车>,则以下程序的输出结果是( )。 main() {int a,b; scanf("%d",&A); b=(a>=0)?a:-a; printf("b=%d",B); }
第15题:
若执行下列程序时从键盘上输入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
第16题:
以下程序运行后的输出结果是( )。
include<stdio.h>
main()
{ int x=20;
printf("%d", 0<x<20);
printf("%d\n", 0<x && x<20);
}
第17题:
以下程序运行后,输出结果是______。 #define P4.5 #define S(x)P*x*x #include<stdio.h> main() { int a=2,b=3; printf("%.1f\n",S(a+b)); }
A.49.5
B.112.5
C.18
D.24
第18题:
若执行以下程序时从键盘上输入9,则输出结果是( )。 main( ) { int n; scanf(”%d”,&n); if(n++<10)printf(”/%d\n”,n); else printf(”%d\n”,n--); }
A.11
B.10
C.9
D.8
第19题:
下列程序的输出结果是( )。
#include<stdio.h>
main()
{ int a=4;
printf("%d\n",(a+=a-=a*A) );
}
A.-8
B.14
C.0
D.-24
第20题:
下列程序运行时输入1234567<CR>,则输出结果是______。
include<stdio.h>
main()
{ int a=1,b;
scanf("%2d%2d",&a,&b);printf("%d %d\n", a,b);
}
本题考查的重点是scanf函数的调用。scanf(“格式化字符串>”,地址表>),格式化字符串后可以加上场宽,本题中两个变量的场宽都为2,所以输入1234567CR>后,变量a的值为12。变址b的值为34,从而输出为12 34。
第21题:
以下程序运行后的输出结果是()。 main( ) {int a=1,b=3,c=5; if(c=a+b) printf(“yes”); else printf(“not”); }
第22题:
第23题:
0
-12
-20
10