al__nasim

series.c

Jan 19th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,n,x,r=1,sum=0;
  5.     printf("Enter the value of X:");
  6.     scanf("%d",&x);
  7.     printf("\nEnter the value of range for series:");
  8.     scanf("%d",&n);
  9.     for(i=1;i<=n;i++)
  10.     {
  11.         r=r*x;
  12.         sum+=r;
  13.     }
  14.     printf("\nThe sum is:");
  15.     printf("%d\n",sum);
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment