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.
C/C++,java,python c++ keywords, identifiers, data types,variables,modifiers,storage classes,operators,for loop ,while loop,do while loop,if else statement,nested loops,break continue goto statement,functions ,call by value call by reference ,arrays ,strings,pointers,data structures ,classes and objects,inheritance,polymorphism,operator overloading,function overloading,data abstraction,data encapsulation,dynamic memory allocation for array and objects,function templates,class templates,
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.
Integer N
Square root of N (integer part only)
0 <= N <= 10^8
10
3
4
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;
}
0 comments:
Post a Comment