Program to calculate area of square

Description

To calculate area of a square use formula
  area = side x side

C/C++

/* C Program to calculate area of square */
//Save it as AreaSquare.c

#include<stdio.h>
int main(){

    float side, area;

    printf("Enter side of a square : ");
    scanf("%f",&side);

    area = (side * side);

    printf("The area square : %.3f",area);

    return 0;
}
Input:
Enter side of a square : 25

Output:
The area square : 625.000

Java

/* Java Program to calculate area of square */
//Save it as AreaSquare.java

import java.io.*;
import java.util.Scanner;

public class AreaSquare {

    public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);
        
            float side, area;

        System.out.println("Enter side of a square : ");
        side = scanner.nextFloat();

        area = (side * side);
        
        System.out.println("The area square : " + area);
    }
}
Input:
Enter side of a square : 
25

Output:
The area square : 625.0

Related Programs

1) Program to calculate area of a circle
2) Program to calculate area of triangle
3) Program to calculate Area Of right angle triangle
4) Program to calculate area of a Rectangle
5) Program to calculate volume and surface area of cube
6) Program to calculate volume and surface area of cylinder
7) Program to calculate Volume and Surface Area of Sphere
Share Me

Leave a Reply