首页 文章资讯内容详情

在C ++中查找正方形和矩形的周长/周长的程序

2026-06-04 1 花语

在本教程中,我们将讨论一个程序,以查找正方形和矩形的周长/周长。

为此,我们将获得矩形或正方形的侧面。我们的任务是找到该正方形或矩形的周长/周长。

示例

#include <iostream> using namespace std; int Circumference(int l, int w) { return (2 * (l + w)); } int main() { int l = 8, w = 8; int c = Circumference(l, w); cout << "Circumference is : " << c << endl; return 0; }

输出结果

Circumference is : 32