Sunday, November 12, 2017

Finding Square Roots Codechef Problem Solution In (C++,C#)

https://www.codechef.com/problems/FSQRT

In C++...........

#include <bits/stdc++.h>

using namespace std;


int main()
{

    int t,n;
    cin>>t;
    while(t--){

   cin>>n;
   int a=sqrt(n);
   cout<<a<<endl;
    }
    return 0;
}


In C#.......

using System;



    public class Program
    {
       public static int Sqrt(int a)
        {

            int s = (int)Math.Pow(a, 0.5);
            return s;

        }
        public static void Main()

        {
            int T = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < T;i++ )
            {
                int n = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine(Sqrt(n));
               }
            Console.ReadKey();
               
        }

    }
   

 

No comments:

Post a Comment