Answer to Question #28102 in C++ for Wedd

Question #28102
write a program in C++ for the function a(n)=((2n+1)/(2n!)^2)
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS