云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C语言基础练习题含答案

C语言基础练习题含答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/6 9:02:32

#include ”stdio.h” #include ”math.h” main() {

float a,b,c,t,disc,w,term1,term2; printf(”enter a,b,c:”); scanf(%f%f%f”,&a,&b,&c); if (【1】)

if (【2】) printf(”no answer due to input error\\n”); else printf(”the single root is %f\\n”, - c/b); else

{ disc=b*b-4*a*c; w=2*a; term1= -b/w; t=abs(disc); term2=sqrt(t)/w; if (【3】)

printf(”complex root\\n real part=%f imag part =%f\\n”, term1,term2); else

printf(”real roots\\n root1=%f root2=%f\\n”, term1+term2,term1-term2);

} }

12.以下程序根据输入的三角形的三边判断是否能组成三角形,若可以则输出它的面积和三角形的类型。请在【】内填入正确内容。 #include ”math.h” #include ”stdio.h” main() {

float a,b,c,s,area;

printf(”please input three edges of a triangle:”); scanf(”%f%f%f”,&a,&b,&c); if (【1】) { s=(a+b+c)/2;

area=sqrt(s*(s-A*(s-B*(s-c));

printf(”\\nthe area of the triangle is: %f”,area); if ((a==b)&&(b==c)) printf(”等边三角形”); else if (【2】) printf(”等腰三角形”): else if (【3】) printf(”直角三角形”): else printf(”一般三角形”):

}

else printf(”不能组成三角形”); }

13.以下程序的功能是判断输入的年份是否是闰年。请在【】内填入正确内容。 #include ”stdio.h” main() {

int year, flag;

printf(”please input the year to jude whether it is a leap year:”); scanf(”%d”,&year); if (year@0==0) flag=1; else if (【1】) flag=1; else 【2】;

if (flag) printf(”%d is a leap year\\n”,year); else printf(”%d is not a leap year!\\n”,year); }

14.以下程序是对用户输入的字母进行大小写转换。请在【】内填入正确内容。 #include ”stdio.h” main() {

char ch;

printf(”please input a letter:”); scanf(”%c”,&ch); if (【1】) ch=ch+32; else if (ch>=’a’ && ch<=’z’) 【2】;

printf(” the converted letter is: %c\\n”,ch); }

15.以下程序是对从键盘输入的任何三个整数,求出其中的最小值。请在【】内填入正确内容。 #include ”stdio.h” main() {

int a,b,c,min;

printf(”please input three numbers:”); scanf(”%d%d%d”,&a,&b,&c); if (【1】) min=b; else min=a; if (min>c) 【2】;

搜索更多关于: C语言基础练习题含答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

#include ”stdio.h” #include ”math.h” main() { float a,b,c,t,disc,w,term1,term2; printf(”enter a,b,c:”); scanf(%f%f%f”,&a,&b,&c); if (【1】) if (【2】) printf(”no answer due to input error\\n”); else printf(”the single root is %f\\n”, - c/b); else { disc=b*b-4*a*c; w=2*a; term1= -b/w; t=abs(disc); term2=sqrt(t)/w; if (【3】) printf(”complex root\\n real part=%f imag part =%

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com