Program to find the perimeter of a square given its area Last Updated : 18 Jan, 2024 Comments Improve Suggest changes Like Article Like Report Write a program to find the perimeter of a square given its area. Examples: Input: Area = 36 square unitsOutput: Perimeter = 24 unitsExplanation: Since the area of the square is 36 square units, so the side of square will be 6 units. Therefore, the perimeter of the square will be 4 * 6 = 24 units. Input: Area = 25 square unitsOutput: Perimeter = 20 unitsExplanation: Since the area of the square is 25 square units, so the side of square will be 5 units. Therefore, the perimeter of the square will be 4 * 5 = 20 units. Approach: To solve the problem, follow the below idea: The area of a square is given by Area=side×side. We can find the side length by taking the square root of the area. Once the side length is known, the perimeter can be calculated as Perimeter=4×side. Step-by-step algorithm: Calculate the side length using the square root of the area.Calculate the perimeter using the formula Perimeter=4 × side.Print the calculated perimeter.Below is the implementation of the algorithm: C++ #include <cmath> #include <iostream> using namespace std; int main() { double area, side, perimeter; // Example Test Case area = 16; // Calculate side length side = sqrt(area); // Calculate perimeter perimeter = 4 * side; // Display result cout << "Perimeter: " << perimeter << endl; return 0; } C #include <math.h> #include <stdio.h> int main() { double area, side, perimeter; // Example Test Case area = 16; // Calculate side length side = sqrt(area); // Calculate perimeter perimeter = 4 * side; // Display result printf("Perimeter: %.2f\n", perimeter); return 0; } Java import java.util.Scanner; public class SquarePerimeter { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double area, side, perimeter; // Example Test Case area = 16; // Calculate side length side = Math.sqrt(area); // Calculate perimeter perimeter = 4 * side; // Display result System.out.println("Perimeter: " + perimeter); } } Python3 import math # Example Test Case area = 16 # Calculate side length side = math.sqrt(area) # Calculate perimeter perimeter = 4 * side # Display result print(f"Perimeter: {perimeter}") C# using System; class Program { static void Main() { double area, side, perimeter; // Example Test Case area = 16; // Calculate side length side = Math.Sqrt(area); // Calculate perimeter perimeter = 4 * side; // Display result Console.WriteLine("Perimeter: " + perimeter); } } JavaScript // Example Test Case let area = 16; // Calculate side length let side = Math.sqrt(area); // Calculate perimeter let perimeter = 4 * side; // Display result console.log(`Perimeter: ${perimeter}`); OutputPerimeter: 16Time Complexity: O(log N), because it takes O(logN) time to calculate the square root of N.Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Program to find the perimeter of a square given its area C code_r Follow Improve Article Tags : DSA Similar Reads Program to find the side length of a square given its area Write a program to find the side length of a square with given area. Examples: Input: Area = 16 square units Output: Side length = 4 units Input: Area = 25 square meters Output: Side length = 5 meters Approach: To solve the problem, follow the below idea: The side length of a square can be calculate 2 min read Program to find the area of a Square What is a square ? Square is a flat shape, in one plane, defined by four points at the four corners. A square has four sides all of equal length, and four corners, all right angles (90 degree angles). A square is a kind of rectangle but with all sides equal. Formula : Area = side * side Examples: In 3 min read Program to find the Area and Perimeter of a Semicircle Given the radius of the semicircle as r, the task is to find out the Area and Perimeter of that semicircle.Examples: Input: r = 10 Output: Area = 157.00, Perimeter = 31.4 Input: r = 25 Output: Area =981.250000, Perimeter = 78.500000 Approach: In mathematics, a semicircle is a one-dimensional locus o 5 min read JavaScript Program to Find Perimeter of Square Given the length of one side, our task is to find the perimeter of a square in JavaScript. The perimeter of a square is the total length of its four sides. It can be calculated by multiplying the length of one side by 4 and all its angles measure 90 degrees. Example: Formula for calculating Perimete 2 min read If the side of a square is doubled, then find its perimeter Square is a geometrical figure which is formed of four equal sides. It is a regular quadrilateral where all the angles are right angles. Basically, it can be considered as a special case of a rectangle, where all the sides are equal in length. For instance, a square courtyard. Properties of square A 3 min read Like