ਹੇਠ ਲਿਖੀ ਸੀਰੀਜ ਦਾ ਜੋੜ ਪਤਾ ਕਰਨ ਲਈ ਪ੍ਰੋਗਰਾਮ ਲਿਖੋ।

ਸੀਰੀਜ: x2 + x4 + x6 +..........+ xn

#include<stdio.h>
#include<conio.h>

void main()
{
      int x, n, i;
      long sum=0;
      printf("Enter value of x:");
      scanf("%d",&x);
      printf("Enter value of n:");
      scanf("%d",&n);
      for(i=2;i<=n;i+=2)
      {
            sum+=pow(x,i);
      }
      printf("Answer is %ld",sum);
      getch();
}

Output:

Comments