Skip to content

Commit cb09726

Browse files
authored
Create nthroot.cpp
1 parent f594f45 commit cb09726

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Math/nthRoot/cpp/nthroot.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
```cpp
2+
3+
#include<iostream>
4+
#include<math.h>
5+
6+
using namespace std;
7+
8+
double nthroot(int b,int n)
9+
{
10+
11+
return pow(b,-n);
12+
13+
}
14+
15+
int main()
16+
{
17+
18+
int b,n;
19+
20+
cout<<"Enter the number whose nth root is to be calculated: ";
21+
cin>>b;
22+
23+
cout<<"Enter the exponent n for the nth root: ";
24+
cin>>n;
25+
26+
cout<<"The "<<n<<"th root of "<<b<<" is equal to "<<nthroot(b,n);
27+
28+
return 0;
29+
30+
}
31+
32+
```

0 commit comments

Comments
 (0)