मराठी

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×