300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > c语言程序运行结果怎么看 c语言程序的运行结果.ppt

c语言程序运行结果怎么看 c语言程序的运行结果.ppt

时间:2022-06-11 03:13:45

相关推荐

c语言程序运行结果怎么看 c语言程序的运行结果.ppt

c语言程序的运行结果

写出程序的运行结果辅导 例1:写出下列程序的运行结果: #include main() {float x,y; scnf(“%f”.&x); if(x<0.0) y=0.0; else if ((x<5.0)&&(x!=2.0)) y=1.0/(x+2.0); else if(x<10.0) y=1.0/x; else y=10.0; printf)”%f\n”,y); } 例2:写出下列程序的运行结果: #include main() {int num=0; while(num<=2) {num++; printf(“%d\n”,num);} } 例3:写出下列程序的运行结果: #include main() {int a,b; for(a=1,b=1;a<=100;a++) {if(b>=20) break ; if(b%3==1) {b+=3; continue; } b-=5; } Printf(“%d\n”,a); } 例4:写出下列程序的运行结果: #include main() {int x=1,y=0,=0,b=0; switch(x) {case 1: switch(y) {case 0: a++;break case 1: b++;break; } case 2: a++;b++;break; printf(“%d %d\n”,a,b); } #include main() {int k=4,m=1,p; p=func(k,m); printf(“%d, ”p); p=func(k,m); printf(“%d\n”p); } 例6:写出下列程序的运行结果: int d=1; fun(int p) { int d=5; d+=p++; printf(“%d ”,d); } main() {int a=3; fun(a); d+=a++; printf(“%d\n”,d); } 例7:写出下列程序的运行结果: #include main() {int i,j,row,column,m; static int array[3][3]={{100,200,300}, {28,72,-30}, {-850,2,6}}; m=array[0][0]; for(i=1;i<3;i++) for(j=0;j<3;j++) if(array[i][j] main() {long n; long f(long); scanf(“%ld”,&n); printf(“ld”,f(n)); } long f(long n) {if(n==1||n==2) return(1); else return(f(n-1)+f(n-2)); } 例9:写出下列程序的运行结果: #include #define SUB(X,Y) (X)*Y main() {int a=3,b=4; printf(“%d\n”,SUB(a++,b++)); } 例10:写出下列程序的运行结果: #include #include void fun(char *w,int m) {char s,*p1,*p2; p1=w;p2=w+m-1; while(p1

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。