C - A4P4 - Sum of the cube of individual elements of array




/* Write a program to sum the cube of individual element of an array */


#include<stdio.h>
#include<conio.h>
void main()
{
    int arr[5],cb[5],a,sum=0;
    clrscr();
    for(a=0;a<5;a++)
    {
        printf("Enter Element [%d] -> ",a);
        scanf("%d",&arr[a]);
        cb[a]=arr[a]*arr[a]*arr[a];
        sum=sum+cb[a];
    }
    printf("\n\n:: Cube of All Elements :: \n\n");
    for(a=0;a<5;a++)
    {
        printf("Cube of [%d] -> %d \n",a,cb[a]);
    }
    printf("\n\nSum of all Elements -> %d",sum);
    getch();
}

Post a Comment