C program to find the sum of series 1+x+ x^2 + x^3+. . . +x^n
on
Get link
Facebook
X
Pinterest
Email
Other Apps
Code: #include<stdio.h> int main() { int x,n,t; long sum=1; printf("Enter the value of 'x': "); scanf("%d",&x); printf("\nEnter the value of 'n': "); scanf("%d",&n); t=x; while(n>0) { sum=sum+t; t=t*x; n--; } printf("Sum of the series=%ld",sum); }
Comments
Post a Comment