#include<stdio.h>//header file
#include<conio.h>//header file
#include<math.h>//header file
void main() //starting of the main() function
{
int x,n,i; //declaration of the variables
long int s=0;
clrscr();
printf("program that calculates the sum of a no with increasing powers.");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the value x and its power for range");//taking input from the user
scanf("%d%d",&x,&n);
if(x==0)
{
printf("\n\n\n\t\t------------OUTPUT------------");
s=0;
printf("\n\nthe required sum for 1+x+x^2+x^3+______+x^n is=%ld",s);//printing output
getch();
exit(0);
}
if(n==0)
{
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nrange is not appropriate");//printing output
getch();
exit(0);
}
for(i=1;i<=n;i++)
s=s+pow(x,i-1);
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe required sum for 1+x+x^2+x^3+______+x^n is=%ld",s);//printing output
getch();
}