Tagged: 

  • Square Root

     Indu updated 1 month ago 2 Members · 2 Posts
  • Akash 

    Administrator
    at

    Write a program to calculate a square root of a number.

  • Indu

    Member
    at

    import java.util.Scanner;

    public class SquareRoot {

    public static void main(String[]args){

    Scanner Scan=new Scanner(System.in);

    System.out.println(“Enter the number”);

    int n=Scan.nextInt();

    double sr=n/2;

    double temp;

    do{

    temp=sr;

    sr=(temp+(n/temp))/2;

    }while((temp-sr)!=0);

    System.out.println(“Square root of the given number is : “+sr);

    }

    }

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 21st September 2020. Attend one week free demo classes.Register Now

New Report

Close