Skip to content

Commit c6b657a

Browse files
committed
truncated_square_root.cpp:Removed library function
Removed library functions as requested.
1 parent c1e43d2 commit c6b657a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Math/truncated_square_root/a.out

-88 Bytes
Binary file not shown.
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#include <iostream>
22
#include <cstdio>
33
#include <cstdlib>
4-
#include <cmath>
54

65
using namespace std;
76

87
int main() {
9-
double a = 0;
10-
cout<<"Enter an integer:"<<endl;
11-
cin>>a;
12-
if (a <= 0) return 0;
13-
printf("Square root of %lf is: %.0lf \n",a,floor(sqrt(a)));
8+
long long int n,x = 0,count=0;
9+
cout<<"Enter an integer: "<<endl;
10+
cin>>n;
11+
for(int i = 1;x <= n;i += 2) {
12+
x += i;
13+
count++;
14+
}
15+
printf("Square root of %lld is: %lld\n",n,count-1);
1416
return 0;
1517
}

0 commit comments

Comments
 (0)