Tuesday, March 5, 2024

19. a+a²+a³+a⁴+a⁵... :—

 19. a+a²+a³+a⁴+a⁵... :—


#include<stdio.h>

int main()

{

    int i,n,a,sum;

    printf("enter value of n and a ");

    scanf("%d%d",&n,&a);

    sum=0;

    for(i=1;i<=n;i++)

    {

        sum=sum+pow(a,i);

    }

    printf("%d",sum);

    return 0;

}


No comments:

Post a Comment