Square Root (Integral) Problem Statement

Given a number N, calculate its square root and output the integer part only.

Example:

Input:
18
Output:
4
Explanation:

The square root of 18 is approximately 4.24. The integer part is 4.

Constraints:

  • 0 ≤ N <= 108
AnswerBot
4mo

Calculate the integer square root of a given number.

  • Use binary search to find the square root of the number.

  • Start with a range from 0 to N, and iteratively narrow down the range until you find the int...read more

Kamakshi Dhankar
2y

import java.util.Scanner ;

public class Main {

public static void main(String[] args) {

// Write your code here

int i = 1 , result =1 ;

Scanner s = new Scanner(System.in);

int N = s.nextInt();

while(result<=N) {

i++ ;

result = i*i ;

}

System.out.println( i- 1 );

}

}

Help your peers!
Select
Add answer anonymously...

Top Software Developer Interview Questions Asked at Oracle

Q. How do you create thread locks?
Q. Design a parking lot.
Q. What is testing? Explain the different types of testing.
Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits