TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to calculate the area of rectangle

Program to calculate the area of rectangle on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to calculate the area of the rectangle

Area of a rectangle is the amount of space occupied by the rectangle. A rectangle can be defined as the plain figure with two adjacent sides equal in length. The 4 angles present in the rectangle are also equal. A rectangle can be divided into 4 similar square. The measurement of each interior angle in a rectangle is 90 degrees.

Area of a rectangle is the number of square units takes to fill a rectangle completely.

Formula
A= W x H

where

A is the area of the rectangle
W is the width of the rectangle
H is the height of the rectangle

Algorithm

  1. Define the width of the rectangle.
  2. Define the Height of the rectangle.
  3. Define Area of the rectangle.
  4. Calculate the area of the rectangle by multiplying the width and height of the rectangle.
  5. Assign the area of the rectangle to the area variable.
  6. print the area of the rectangle.

Complexity

O(1)


Solution

C Program

#include 
int main()
{
    int width=5;
    int height=10;
    int area=width*height;
    printf("Area of the rectangle=%d",area);
}

Output:

Area of the rectangle=50 

PHP Program

<?php  
    $width=5;
    $height=10;
    $area=$width*$height;
    echo "Area of the rectangle=";
    echo $area;
?>  

Output:

Area of the rectangle=50 

Java Program

public class rectangle{
    public static void main(String args[])
    {
    int width=5;
    int height=10;
    int area=width*height;
        System.out.println("Area of rectangle="+area);
     }
}

Output:

Area of rectangle=50

C# Program

using System;	
public class Program
{
	public static void Main()
	{
   int width=5;
   int height=10;
   int area=width*height;
   Console.WriteLine("Area of rectangle="+area);
	}
}

Output:

Area of rectangle=50

Python Program

width=5
height=10
area=width*height
print("Area of rectangle="+str(area))

Output:

Area of rectangle=50  

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf