Skip to main content
Browse topics

Area of Square Example C++ Program in C++

1 min read Updated June 30, 2026
Share

About this program

This is an example program in c common example program. Read the concept first: C++ Variables and Data Types, then study the code and output below.

Definition

In classical times, the second power was described in terms of the area of a square, as in the above formula. This led to the use of the term square to mean raising to the second power. Thus the area of the square is twice the length of the square.

Area Of Square Formula

cpp
The area of a rectangle is written as,
cpp
A=s^2
cpp
here,
A=Area
s=side of the square

Area Of Square Example Program

cpp
/*## Area Of Square In C++*/
/*##Calculation C++ Programs, Datatype C++ Programs, Basic C++ Programs*/

#include <iostream>
#include<conio.h>
#include<stdlib.h>

using namespace std;

int main() {
   // Declare Variables
   float length, area;

   cout << "Simple C++ Program : Area Of Square\n";
   cout << "\nEnter the Length of Square : ";
   cin>>length;

   area = length * length;
   cout << "\nArea of Square : " << area;

   getch();
   return (0);
}

Sample Output

cpp
Simple C++ Program : Area Of Square

Enter the Length of Square : 6

Area of Square : 36

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C++ program do?
It is a C++ example program that demonstrates Area of Square Example, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses reading user input, illustrating a common pattern in C++ programming.

Related tutorials

Search tutorials