哈工大C语言程序设计精髓-第一周作业

题目内容:

使用printf()在屏幕上输出 hello world!

#include  <stdio.h>

int main()

{

    printf("hello world!\n");

    return 0;

}

################################################################################################

题目内容:

使用printf()函数在屏幕上输出以下多行信息:

hello world!

hello hit!

hello everyone!

 

#include  <stdio.h>

int main()

{

    printf("hello world!\n");
        printf("hello hit!\n");
        printf("hello everyone!\n");

    return 0;

}

###################################################################################################

题目内容:

编程并输出半径r=5.3的半圆弧长(提示:半圆弧长不应该加直径的长度。)及该半圆弧与直经围成的半圆的面积的取值为3.14159。要求半径r和必须利用宏常量表示。

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define pi 3.14159
int main()
{
    float r,c,s;
    r=5.3;
    c=2*r*pi;
    s=r*r*pi;
    printf("Area=%.5f\n",s/2);
    printf("circumference=%.5f\n",c/2);
    return 0;
}

################################################################################################

题目内容:

编程并输出长1.2、宽4.3、高6.4的长方体的体积。要求长方体的长、宽、高必须利用const常量表示。程序中用到的数据类型均为为 double类型。

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    double d;
    const  double a=1.2;
    const  double b=4.3;
    const  double c=6.4;
    d=a*b*c;
    printf("volume=%.3f\n",d);
    return 0;
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值