Answer to Question #28102 in C++ for Wedd
write a program in C++ for the function a(n)=((2n+1)/(2n!)^2)
1
2013-04-10T10:22:47-0400
#include <iostream>
using namespace std;
long double calc(int n) {
long double res = (2*n + 1) / 4.0;
for (int i = 2; i <= n; i++)
& res /= i*i;
return res;
}
int main() {
cout << "Input n: ";
int n;
cin >> n;
cout << "(2n+1)/(2n!)^2 = " << calc(n) << endl;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment