power series

power series - p*=x; return p; } void main() { int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Q :write C++ function that return power of A b then calculating this series in main program? = + + +…+ ( * + ) y x1 x3 x5 x n 2 1 #include<iostream.h> double power( int x,int y) { double p=1; for(int i=0;i<y;i++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: p*=x; return p; } void main() { int x,y,n,s=0; cout&lt;&lt;&quot;\nenter x : = &quot;; cin&gt;&gt;x; cout&lt;&lt;&quot;\nenter n : = &quot;; cin&gt;&gt;n; for(int i=0;i&lt;n;i++) s+=power(x,(i*2+1)); cout&lt;&lt;s; }...
View Full Document

Ask a homework question - tutors are online