Answer to Question #20842 in C++ for Priya Darshani
Write a program in c++ and algorithm to find the sum of 'n' term of a series
1-1/2+1/4-1/8+1/16+............
1
2012-12-20T07:46:40-0500
#include <math.h>
#include "iostream"
using namespace std;
int main()
{
int i;
float s=0,k,h;
cout<<"Enter n : ";
cin>>i;
for(int t=0;t<i;t++){
s=s+1/(pow(2,t));
}
cout<<"Sum : "<<s<<endl;
system ("PAUSE");
}
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