Dremendo Tag Line

Calculate area of a square in C++

cin - Question 11

In this question, we will see how to input side of a square in C++ programming using the cin statement and find its area. To know more about cin statement click on the cin statement lesson.

Q11) Write a program in C++ to input side of a square and find its area.

Formula: area = side * side

Program

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

using namespace std;

int main()
{
    int s,a;
    cout<<"Enter side of a square ";
    cin>>s;
    a=s*s;
    cout<<"Area="<<a;
    return 0;
}

Output

Enter side of a square 5
Area=25
video-poster