jsp求矩形周长和面积_C程序查找矩形的面积和周长

使用C语言编写程序,输入矩形的长度和宽度,计算并输出其面积和周长。矩形面积公式为长度乘以宽度,周长公式为两倍长度加两倍宽度。
摘要由CSDN通过智能技术生成

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求矩形周长和面积

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值