Skip to content

Commit 4d6e97b

Browse files
committed
added square root function in c++
1 parent ca11cd7 commit 4d6e97b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Math/squareroot

Lines changed: 0 additions & 1 deletion
This file was deleted.

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)