power series

power series - p*=x return p void main int x,y,n,s=0...

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<<"\nenter x : = "; cin>>x; cout<<"\nenter n : = "; cin>>n; for(int i=0;i<n;i++) s+=power(x,(i*2+1)); cout<<s; }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online