首页  >  文章  >  后端开发  >  平行四边形周长的C程序

平行四边形周长的C程序

WBOY
WBOY转载
2023-09-01 11:01:051454浏览

平行四边形周长的C程序

我们已知平行四边形的边,任务是生成具有给定边的平行四边形的周长并显示结果

什么是平行四边形?

平行四边形是一种二次方程,具有 -

  • 对边平行
  • 对角相等
  • 多边形对角线互相平分
  • li>

下图所示的“a”和“b”是平行四边形的边,图中所示的边是平行的。

平行四边形周长的C程序

平行四边形的周长/周长定义为

平行四边形的周长 = 2(a + b) 

                                             = 2 * a + 2 * b

示例

Input-: a = 23 and b = 12
Output-: Circumference of a parallelogram is : 70.00
Input-: a = 16.2 and b = 24
Output-: Circumference of a parallelogram is : 80.4

算法

START
Step 1-> Declare function to calculate circumference of parallelogram
   float circumference(float a, float b)
   return ((2 * a) + (2 * b))
Step 2-> In main()
   Declare float a = 23, b = 12
   Call circumference(a, b)
STOP

示例

#include <stdio.h>
//function for circumference of parallelogram  
float circumference(float a, float b) {
   return ((2 * a) + (2 * b));
}
int main() {
   float a = 23, b = 12;
   printf("Circumference of a parallelogram is : %.2f", circumference(a, b));
   return 0;
}

输出

Circumference of a parallelogram is : 70.00

以上是平行四边形周长的C程序的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除