中国大学(慕课)哈工大C语言程序设计精髓练兵区第一周

这是第一周的一些东西 简单记录一下

1、
题目内容:
使用printf()在屏幕上输出 hello world!

#include  <stdio.h>
int main()
{
	 printf("hello world!\n");
		 return 0;
}

2、
题目内容:
在屏幕上输出多行信息
使用printf()函数在屏幕上输出以下多行信息:hello world!hello hit!hello everyone!提示:在printf()函数中转义字符‘\n’表示换行。

#include  <stdio.h>
int main()
{
 printf("helloworld!\n");  
 printf("hello hit!\n");        
 printf("hello everyone!\n"); 
      	return 0;
}

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

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

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

#include<stdio.h>
int main()
{
	const double a=1.2,b=4.3,c=6.4;
	printf("volume=%.3f\n",a*b*c);
	 return 0;
}
  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值