C++ Online Compiler
Example: C++ program to find the perimeter of a rectangle
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to find the perimeter of a rectangle #include <iostream> using namespace std; int main() { float l, w, p; cout << "Enter the length & width of the rectangle::\n"; cin >> l; cin >> w; /* Calculate perimeter of rectangle */ p = 2 * (l + w); /* Print output */ cout << "\nThe Perimeter of rectangle = " << p << " units"; return 0; }
5 7
Output
Clear
ADVERTISEMENTS