हिंदी

Write a program to find sum of the series S = 1 + x + x2 +..... + xn

Advertisements

प्रश्न

Write a program to find sum of the series

S = 1 + x + x2 +..... + xn

टिप्पणी लिखिए
Advertisements

उत्तर

using namespace std;
#include
int main()
{
int sum=1,x,i,t,n;
cout<<“\nEnter N value”;
cin>>n;
cout<<“\nEnter x value … “;
cin>>x;
t=x;
for(i=l;i<=n;i++)
{
sum = sum + t;
t = t * x;
}
cout<<“SUM = “<<sum;
}
Output

shaalaa.com
Statements
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 10: Flow of Control - Evaluation - Section - D [पृष्ठ १७९]
Advertisements
Share
Notifications



      Forgot password?
Use app×