第一范文网 - 专业文章范例文档资料分享平台

C语言基础练习题含答案

来源:用户分享 时间:2025/6/18 16:10:25 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

A.1 B.2 C.3 D.4 2.2 填空题

1.若从键盘输入58,则输出结果是___585858_____。 #include ”stdio.h” main() { int a;

scanf(”%d”, &a); if (a>50) printf(”%d”, a); if (a>40) printf(”%d”,a); if (a>30) printf(”%d”,a); }

2.设int x=9,y=8;表达式x==y+1的结果是__1______。 3.定义int x,y;执行y=(x=1,++x,x+2);后, y的值是__4______。4.定义int x=10,y,z; 执行y=z=x; x=y==z;后,x的结果是 1 。5.设int a=1,b=2,c,d,e; 执行 c=(-a++)+(++b); d=(b--)+(++a)-a; e=(a/(++b))-(a/(--a));

请问a,b,c,d,e的结果是:2 3 2 3 0。

6.设int a=2,b=3,c,d,e,f; 执行 c=(a++>= --b); d=(a==++b); e=(a--!=b); f=(++a>b--);

请问a,b,c,d,e,f的结果是:_3 2 1 1 0 0_______。 7.以下程序的运行结果是__2 0 0______。 #include ”stdio.h” main() {

int a,b,c,s,w,t; s=w=t=0; a= -1; b=3; c=3; if (c>0) s=a+b; if (a<=0) { if (b>0) if (c<=0) w=a-b; }

else if (c>0) w=a-b; else t=c;

printf(”%d %d %d”, s,w,t); }

8.以下程序的运行结果是__100______。 #include ”stdio.h” main() {

int a,b,c,d,e; a=c=1; b=20; d=100; if (!a) d=d++; else if (!b) if (d) d= --d; else d= d--; printf(”%d\\n\\n”, d); }

9.以下程序的运行结果是_6 250 (换行)5 1 0 0______。 #include ”stdio.h” main() {

int a, b= 250, c; if ((c=b)<0) a=4; else if (b=0) a=5; else a=6;

printf(”\\t%d\\t%d\\n”,a,c); if (c=(b==0)) a=5;

printf(”\\t%d\\t%d\\n”,a,c); if (a=c=b) a=4; printf(”\\t%d\\t%d\\n”,a,c); }

10.下面程序根据以下函数关系,对输入的每个x值,计算出y 值。请在【】内填空。 main() { int x,y;

scanf(”%d”, &x); if (【1】) y=x*(x+2); else if (【2】) y=1/x; else if (x<=-1) y=x-1; else 【3】;

if (y!= -1) printf(”%d”,y); else printf(”error”); }

11.以下程序的功能是计算一元二次方程ax2+bx+c=0的根。请在【】内填入正确内容。

搜索更多关于: C语言基础练习题含答案 的文档
C语言基础练习题含答案.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c50iya3pd7h7l7tx29ybm0wacw0f2p400g8t_10.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top