Computer Science, asked by get2saad, 8 months ago

write a program to calculate and print the area of a square the whose side is 3cm

Answers

Answered by sam3315
0

Answer:

import java.util.*;

public class square{

public static void main (String args[])

{

Scanner jn =new Scanner (System.in);

double s, area=0.0d;

System.out.prjntln("enter side of square");

s=in.nextDouble();

area=s*s;

System.out.println(area);

}}

pls mark as the brainliest

Answered by sanjiththesupernigha
0

Answer:

C :

#include<stdio.h>

 

int main() {

  int side, area;

 

  printf("\nEnter the Length of Side : ");

  scanf("%d", &side);

 

  area = side * side;

  printf("\nArea of Square : %d", area);

 

  return (0);

}

C++ :

#include<stdio.h>

 

int main() {

  int side, area;

 

  printf("\nEnter the Length of Side : ");

  scanf("%d", &side);

 

  area = side * side;

  printf("\nArea of Square : %d", area);

 

  return (0);

}

Java :

import java.util.Scanner;

class SquareAreaDemo {

  public static void main (String[] args)

  {

      System.out.println("Enter Side of Square:");

      //Capture the user's input

      Scanner scanner = new Scanner(System.in);

      //Storing the captured value in a variable

      double side = scanner.nextDouble();

      //Area of Square = side*side

      double area = side*side;  

      System.out.println("Area of Square is: "+area);

  }

}

C# :

using System;  

 

class GFG  

{  

   static int areaSquare(int side)  

   {  

       int area = side * side;  

       return area;  

   }  

     

   // Driver code  

   public static void Main()  

   {  

       int side = 4;  

         

       Console.WriteLine(areaSquare(side));  

   }  

}  

PHP :

function areaSquare($side)  

{  

   $area = $side * $side;  

   return $area;  

}  

 

// Driver Code  

$side = 4;  

echo(areaSquare($side));

Python(note : its for python 3) :

def areaSquare( side ):  

   area = side * side  

   return area  

 

# Driver Code  

side = 4

print(areaSquare(side))

Explanation:

Similar questions