C语言程序设计精髓第一周编程

正在学习哈工大苏小红老师的c语言程序设计精髓,如果您也有兴趣,可以联系我一起学习哦!

Hello world!

题目内容:

使用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>

#define PI 3.14159
#define R 5.3

int main() {
    printf("Area=%.5f\n", PI * R * R / 2);
    printf("circumference=%.5f\n", PI * R);
    return 0;
}

计算长方体的体积

题目内容:

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

#include  <stdio.h>

int main() {
    const double length = 1.2;
    const double width = 4.3;
    const double hight = 6.4;

    printf("volume=%.3f\n", length * width * hight);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值