Skip to content

Commit 063eea0

Browse files
Merge pull request matthewsamuel95#158 from JhaPrajjwal/master
Added Square root program in c++.
2 parents 98d586d + 4d6e97b commit 063eea0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Math/squareroot/square_root.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<iostream>
2+
#include<math.h>
3+
using namespace std;
4+
5+
int sqrt(int x)
6+
{
7+
if(x==0) return 0;
8+
9+
int counter=1;
10+
while(pow(counter,2)<=x){
11+
counter++;
12+
}
13+
counter--;
14+
return counter;
15+
}
16+
int main()
17+
{
18+
int n;
19+
cout<<"Enter Number\n";
20+
cin>>n;
21+
cout<<"The square root of the number is: "<<sqrt(n)<<endl;
22+
return 0;
23+
}

0 commit comments

Comments
 (0)