C语言2011习题集(10)

时间:2025-07-11

8 为表示关系x≥y≥z,应使用C语言表达式_(x>=y)&&(y>=z)__。 9 下面的程序段的输出结果是_**3__。

int x=3;

if((x%2)?printf("**%d",x):printf("##%d\n",x));

10 以下程序运行后的输出结果是_14__。

main()

{ int m=5;

switch(m/2)

{ case 1: m++;

case 2: m+=3; case 5: m+=6;break; default: m-=7; }

printf("%d\n",m); }

三 程序填空(每空5分,共30分)

1 下列程序的输出结果是16.00,请填空。

main()

{ int a=9,b=2;

float x= 6.6 ,y=1.1,z; z=a/2+b*x/y+1/2; printf("%5.2f\n",z); }

2 完成以下程序,输入变量a,b,c的值,判断a,b,c能否组成三角形,计算三角形面积。

s p(p a)(p b)(p c)其中p (公式为:。

a b c

2

#include <stdio.h>

#include<math.h>; main()

{ int a,b,c;

float s,p;

printf("please input the value of a,b,c") scanf("%d %d %d", &a,&b,&c );

if(a+b>c && b+c>a && c+a>b && a>0 && b>0 && c>0) { p=(a+b+c)/2.0;

s=sqrt(p*(p-a)*(p-b)*(p-c));

printf("Yes,this is a triangle!\n the area is %.2f.\n",s); }

else printf("No,this is not a triangle!\n") }

循环结构程序设计

一 单项选择题(每题2分,共40分)

C语言2011习题集(10).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219