Finding Square Roots solution in C language - Codechef

  

Finding Square Root

Problem Code: FSQRT


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.

Input

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.

Output

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

Constraints

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

Example - Incorrect Withdrawal Amount (not multiple of 5)

Input:
3
10
5
10000

Output:
3
2
100


. . .

Solution in C.


#include <stdio.h>
#include <math.h>
int main() {
    int t, a;
    scanf("%d",&t);
    whilef(t--) {
        int n;
        scanf("%d",&n);
        a = sqrt(n); printf("%d", a);     } return 0; }


Comments

Popular posts from this blog

ATM solution in C language.- Codechef

MOTIVATION SOLUTION IN C LANGUAGE | CODECHEF | IMDB

APPLE AND ORANGE | HACKERRANK | PROBLEM SOLVING | SOLUTION IN C