Computer Science, asked by rr086051, 2 months ago

find and display the diagonal of a square

taking side of square as an input.​

Answers

Answered by BrainlyProgrammer
7

Answer:

//Java

import java.util.*;

class Diag{

public static void main (String ar []){

Scanner sc=new Scanner (System.in);

System.out.println("Enter side of a square");

int s=sc.nextInt();

System.out.println("Diagonal:"+(s*Math.sqrt(2)));

}

}

#Python

import math

s=(int)(input("Enter side of a square"))

print("Diagonal",(s*(math.sqrt(2))))

•Required Output Attached

Attachments:
Answered by shivikajaiswal16
2

Explanation:

import java.util.Scanner;

public class Diagonal

{

public static void main(String[ ] args)

{

Scanner scn = new Scanner(System.in);

System.out.println("Enter a diagonal of a square")

int a = scn.nextInt();

System.out.println("Diagonal="+(s*Math.sqrt(2)));

}

}

Similar questions