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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值