Computer Science, asked by biswastirthankar199, 1 month ago

write a program to calculate the area of a square. using scanner​

Answers

Answered by MrSovereign
1

☘️\Large{\blue{\bold{To\;Write:}}}

  • A program to calculate the area of a square.

☘️\Large{\blue{\bold{Solution:}}}

Properties of Square:-

Area of the square is the amount of space occupied by a square. Square refers to a plane figure with four equal straight sides and four right angles.

Formula:-

  • area = width × height
  • Area of square will be calculated as :
  • area = side²
  • since width = height;

Algorithm:-

  • Define the height of any one side of the square as 's.'
  • Calculate the area of the square by multiplying s with s
  • Define the area_square as the area of the square.

Complexity:-

  • O(1)

C Program:-

#include <stdio.h>

int main()

{

int s=13;

int area_square=s*s;

printf("Area of the square=%d",area_square);

}

Java Program:-

public class shpere{

public static void main(String args[])

{

int s=13;

int area_square=s*s;

System.out.println("Area of the square="+area_square);

}

}

C+ Program:-

using System;

public class Program

{

public static void Main()

{

int s=13;

int area_square=s*s;

Console.WriteLine("Area of the square="+area_square);

}

Python Program:-

s=13

area_square=s*s

print("Area of the square="+str(area_square))

}

ᴍʀꜱᴏᴠᴇʀᴇɪɢɴ࿐

Hope This Helps!!

Similar questions