program to find square root of a given number in c++

 Program to find square root of a given number in C++


Given a number N, find its square root. You need to find and print only the integral part of square root of N.

For eg. if number given is 18, answer is 4.

Input format :

Integer N

Output Format :

Square root of N (integer part only)

Constraints :

0 <= N <= 10^8

Sample Input 1 :

10

Sample Output 1 :

3

Sample Input 2 :

4

Sample Output 2 :

2
C++ Code:
#include <iostream>
#include<cmath>
using namespace std;

int main()
{
	int n ;
	cin>>n;
	float x = sqrt(n);
	int y = x;
	cout << y;
	
}



SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment