Area of Square || C++ program to find Area of a Square || C++
In this, we are going to see that how to find Area of Square using C++ program.

The formula to calculate is,

Area of Square = (side)*(side)

The Code given below can be used in TURBO C++ Compiler

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

void main()
{
    clrscr();
    float area, side;
    cout<<"This program is for Area of Square\n";
    cout<<"Enter the length of the side of a square\n";
    cin>>side;

    // The formula for Area of Square is (side)^2
    area = side*side;
    cout<<"The Area of the square with side "<<side<<" is = "<<area<<" sq units";
    getch();
}
  
  
  
The Code given below can be used in g++/gcc Compiler

#include<iostream>
using namespace std;

int main()
{
    float area, side;
    cout<<"This program is for Area of Square\n";
    cout<<"Enter the length of the side of a square\n";
    cin>>side;

    // The formula for Area of Square is (side)^2
    area = side*side;
    cout<<"The Area of the square with side "<<side<<" is = "<<area<<" sq units";
    return 0;
}
  

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post