9.(C) Print Cubic sum of first n natural number
#include <stdio.h>
int main()
{
int a, b, sum = 0;
printf("Enter the value of a\n");
scanf("%d", &a);
for (b = 1; b <= a; b++) /* 31 jan,2022 If we print something under loop
parenthesis then it will also print those number which we dont need*/
{
sum += b * b * b;
}
printf("The Cubic sum of [1 to %d]is %d\n", a, sum);
return 0;
}
Comments
Post a Comment