Formulas:

Area of rectangle: height*width

Perimeter of rectangle: 2*(height+width)

C Code

#include<stdio.h>
#include<conio.h>

void main()
{
 float width,height,area,perimeter;

 printf("Enter Width of Rectangle: ");
 scanf("%f", &width);

 printf("Enter Height of Rectangle: ");
 scanf("%f",&height);

 area=height*width;

 printf("\nArea of Rectangle: %.2f", area);

 perimeter=2*(height+width);

 printf("\nPerimeter of Rectangle are: %.2f", perimeter);

 getche()
}

C++ Code

#include<iostream>

using namespace std;

int main()
{

 float width,height,area,perimeter;

 cout << "Enter Width of Rectangle: ";
 cin >> width;

 cout << "Enter Height of Rectangle: ";
 cin >> height;

 area=height*width;

 cout << "Area of Rectangle: " << area << endl;

 perimeter=2*(height+width);

 cout << "Perimeter of Rectangle are: " << perimeter << endl;

 return 0;
}

Output:

Other Related Search Terms

  1. C++ program to find area of rectangle
  2. C program to find perimeter of rectangle
  3. C++ and c program for area of rectangle
Share.

I'm a full-stack developer, specializing in the PHP, JS, Wordpress, MEAN Stack, MERN Stack & Django. I hold a high standard of quality in everything that I do.

Leave A Reply