Program to print the perimeter of a rectangle using its height and width as inputs.

Here, we have a basic program example to print the perimeter of a rectangle using different languages. This program is created in c language, c++, Java, and Python.

Program to print the perimeter of a rectangle in C language

#include <stdio.h>
int main() {
   int length, width;
   float perimeter;
   printf("Enter the length : ");
   scanf("%d",&length);
   printf("Enter the width : ");
   scanf("%d",&width);

   perimeter = 2*(length+width);
   printf("Perimeter of the Rectangle is = %f \n", perimeter);
return(0);
}

Program to print the perimeter of a rectangle in C++ language

#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main()
{
	double length, width, perimeter;
	cout<<"Enter the length: ";
	cin>>length;
	cout<<"Enter the width: ";
	cin>>width;
	perimeter=2*(length+width);
	cout<<"Perimeter of the Rectangle is  : "<<perimeter;
}

Program to print the perimeter of a rectangle in Python language

length = float(input("Enter the length of the Rectangle: "))
width = float(input("Enter the width of the Rectangle: "))
perimeter = 2*(length+width)
print("The perimeter of Rectangle is: ", perimeter)

Program to print the perimeter of a rectangle in Java language

import java.util.Scanner;
public class rectangle
{
    public static void main(String[] args)
    {
        float length, width, perimeter;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter the length of the Rectangle: ");
        length = s.nextFloat();
        System.out.print("Enter the width of the Rectangle: ");
        width = s.nextFloat();
        perimeter = 2*(length+width);
	System.out.println("Perimeter of Rectangle is: "+perimeter);
}            
}