jsp求矩形周长和面积
Input length and breadth and calculate the area and perimeter of a rectangle using C program.
输入长度和宽度,并使用C程序计算矩形的面积和周长。
Formula to calculate area of a rectangle: length * breadth
计算矩形面积的公式: 长度*宽度
Formula to calculate perimeter of a rectangle: 2*length + 2*breadth or 2(length + breadth)
计算矩形周长的公式: 2 *长度+ 2 *宽度或2(长度+宽度)
Example:
例:
Input:
length: 2.55
breadth: 10
Output:
Area: 25.50
Perimeter: 25.10
C中矩形的面积和周长 (Area and perimeter of a rectangle in C )
/* C program to calculate the area and perimeter
of rectangle
*/
#include <stdio.h>
int main()
{
/*declare the variables*/
float length;
float breadth;
float area;
float perimeter;
/*length input*/
printf("Enter the length: ");
scanf("%f", &length);
/*breadth input*/
printf("Enter the breadth: ");
scanf("%f", &breadth);
/*Calculating the area and rectangle*/
area = length * breadth;
perimeter = (2 * length) + (2 * breadth);
/*printing the result*/
printf("Area of the rectangle: %.02f\n", area);
printf("Perimeter of rectangle: %.02f\n", perimeter);
return 0;
}
Output
输出量
First run:
Enter the length: 5
Enter the breadth: 4
Area of the rectangle: 20.00
Perimeter of rectangle: 18.00
Second run:
Enter the length: 2.55
Enter the breadth: 10
Area of the rectangle: 25.50
Perimeter of rectangle: 25.10
翻译自: https://www.includehelp.com/c-programs/find-area-and-perimeter-of-the-rectangle.aspx
jsp求矩形周长和面积