Perimeter of Rectangle in C++

Source code :

#include <iostream>

using namespace std;

int main()
{
    
 float length = 2;
 float width = 3;
 float perimeter;
 
 perimeter = 2.0 * ( length + width );
 
 cout<<"Perimeter of Rectangle : "<< perimeter;

 return 0;
}

Output :

Perimeter of Rectangle : 10

Algorithm :

  1. Initialize the values for length and width
  2. Use the perimeter formula to calculate
  3. Finally print the result

Output :


                

Comments :