j.Write a C program to read in two numbers, x and n, and then compute the sum of
this geometric progression: 1+x+x^2+x^3+.............+x^n. For example: if n is 3 and
x is 5, then the program computes 1+5+25+125.

program:

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
   int n, x, i, sum = 0;
   clrscr();
   printf("Enter the limit\n");
   scanf("%d", &n);
   printf("Enter the value of x\n");
   scanf("%d", &x);
   if(x < 0 || n < 0)
   {
      printf("illegal  value");
   }
   else
   {
      for(i = 0; i <= n; i++)
      sum=sum + pow(x, i);
   }
 printf("sum=%d", sum);
   getch();
}



output: