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

news/2024/7/20 1:31:14 标签: 算法, java, python, 小程序, c++

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


http://www.niftyadmin.cn/n/1255724.html

相关文章

xcode加载静态链接库.a文件总是失败

明明项目是对的&#xff0c;代码没有问题&#xff0c;并且把项目作为库项目引入到新项目中没问题&#xff0c;可是一旦把项目编译出.a文件&#xff0c;引入到新项目中不知为何会有几率出现一大堆错误&#xff0c;其实是xcode的缓存机制在作怪&#xff0c;去这个目录&#xff1a…

006_各种网页错误代码线上示例

一、跨域问题的405 随便请求一个不存在网页的返回405是由于跨域请求时nginx会先进行请求方法的判断,然后再去执行响应的方法(get,post等等的),去掉跨域后返回404 二、xxx 转载于:https://www.cnblogs.com/itcomputer/p/9061606.html

booleanvalue_Java布尔类booleanValue()方法及示例

booleanvalue布尔类booleanValue()方法 (Boolean class booleanValue() method) booleanValue() method is available in java.lang package. booleanValue()方法在java.lang包中可用。 booleanValue() method is used to return the value denoted by this Boolean object con…

js基础相关知识

一、js的书写方式 1、内嵌式&#xff1a;使用script标签即可 2、外联式&#xff1a;使用script&#xff0c;并设置 src属性指向文件的路径(注意&#xff1a;如果一个script标签作为外联式引入时&#xff0c;script标签内部不要书写代码&#xff0c;写了也没有意义) 3、行内式&a…

双旋转字符串 字符串哈希_如何从JavaScript中的字符串创建哈希?

双旋转字符串 字符串哈希Hashing a string means decoding it to a certain other string of alphanumeric characters depending on the hashing algorithm used. The reason why hashing is done is to provide security to the string. A common example is passwords. When…

关于计算机的一些理解

计算机专指现代电子计算机&#xff0c;相较于其他计算装置&#xff0c;它是由一些特殊的电子电路和器件实现&#xff0c;有的能存储信息&#xff0c;有的能处理信息。 特殊在哪里&#xff1f;特殊在其内部只有高和低两种电平信号&#xff0c;分别用“1”和“0”表示&#xff0c…

20155227《网络对抗》Exp9 Web安全基础实践

20155227《网络对抗》Exp9 Web安全基础实践 实验内容 关于WebGoatCross-Site Scripting&#xff08;XSS&#xff09;练习Injection Flaws练习CSRF攻击基础问题回答 SQL注入攻击原理&#xff0c;如何防御&#xff1f;原理&#xff1a;SQL注入攻击指的是通过构建特殊的输入作为参…

选择排序python实现

选择排序&#xff08;Selection sort&#xff09;是一种简单直观的排序算法。它的工作原理是每一次从待排序的数据元素中选出最小&#xff08;或最大&#xff09;的一个元素&#xff0c;存放在序列的起始位置&#xff0c;直到全部待排序的数据元素排完。注意每次查找到最小值之…