c语言写园的周长和面积
时间: 2024-06-13 09:08:57 浏览: 101
以下是C语言计算矩形的周长和面积的例子:
```c
#include <stdio.h>
int main() {
int length = 6;
int width = 4;
int perimeter = 2 * (length + width);
int area = length * width;
printf("Perimeter of the rectangle = %d inches\n", perimeter);
printf("Area of the rectangle = %d square inches\n", area);
return 0;
}
```
输出结果为:
```
Perimeter of the rectangle = 20 inches
Area of the rectangle = 24 square inches
```
阅读全文