正在学习哈工大苏小红老师的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;
}