Integer Square Root Calculation

Given a positive integer 'N', compute its square root and return it. If 'N' is not a perfect square, then return the floor value of sqrt(N).

Example:

Input:
N = 25
N = 20
N = 2
Output:
5
4
1

Explanation:

For 'N' = 25, the output is 5 as 5*5 = 25. For 'N' = 20, the output is 4 because the floor value of the square root of 20 is 4. Similarly, for 'N' = 2, the floor value of the square root is 1.

Constraints:

  • 1 <= T <= 5
  • 0 <= N <= 1016
  • Time Limit: 1 sec.
AnswerBot
4mo

Calculate the square root of a positive integer and return the floor value if not a perfect square.

  • Use the sqrt() function to calculate the square root of the given integer.

  • If the square root is not a...read more

Help your peers!
Select
Add answer anonymously...

NetApp Software Developer interview questions & answers

A Software Developer was asked Q. What extracurricular activities did you participate in during college?
A Software Developer was asked Q. If we use a heap in Q6, what are the disadvantages of that approach?
A Software Developer was asked Q. How do you calculate the square root of a number without using math.h?

Popular interview questions of Software Developer

A Software Developer was asked Q1. What extracurricular activities did you participate in during college?
A Software Developer was asked Q2. If we use a heap in Q6, what are the disadvantages of that approach?
A Software Developer was asked Q3. How do you calculate the square root of a number without using math.h?
NetApp 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