Saturday, June 13, 2015

series(1^3 + 2^3 + 3^3+ .....+n^3)


///1^3 + 2^3 + 3^3+ .....+n^3
int main(){

    int n,i;
    int sum=0;

    printf("Enter any end number of this series: ");
    scanf("%d",&n);

    sum = (((n*(n + 1) ) / 2))*(((n*(n + 1) ) / 2));

    printf("\nSum of the series:");

    for(i =1;i<=n;i++){
         if (i!= n)
             printf("%d^3+",i);
         else
             printf("%d^3=%d\n ",i,sum);
    }

    return 0;
}

No comments:

Post a Comment