68 401
Assignments Done
98,5%
Successfully Done
In December 2018

Answer to Question #20842 in C++ for Priya Darshani

Question #20842
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+............
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions