Finding Square Roots Codechef Solution

Hello Programmers In this post, you will know how to solve the Finding Square Roots Codechef Solution.

Finding Square Roots Codechef Solution
Finding Square Roots Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.


In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages .

Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here’s your chance.


The first line of the input contains an integer T, the number of test cases. T lines follow. Each line contains an integer N whose square root needs to be computed.


For each line of the input, output the square root of the input integer, rounded down to the nearest integer, in a new line.


  • 1 <= T <= 20
  • 1 <= N <= 10000





Finding Square Roots CodeChef Solutions in Python

T = int(input())
while T > 0:
   n = int(input())
   sqrt = n ** 0.5
   sqrt_root = round(sqrt)
   T = T - 1

Finding Square Roots CodeChef Solutions in CPP

#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int a;
	cin >> a;
	while (a--){
		long b;
		cin >> b;
		cout << int(sqrt(b)) << endl;

Finding Square Roots CodeChef Solutions in JAVA

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(;
		int T = sc.nextInt();
		for (int tc = 0; tc < T; tc++) {
			int N = sc.nextInt();
	static int solve(int N) {
		int root = (int) Math.ceil(Math.sqrt(N));
		while (root * root > N) {
		return root;

Disclaimer: The above Problem (Finding Square Roots) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Lucky Four Codechef Solution

Leave a Reply

Your email address will not be published. Required fields are marked *