Author : Rahul

Write a program to calculate the sum of cube of n natural numbers.


Program

using System;

namespace ProgrammingQuestion
{
 class Program
 {
   static void Main(string[] args)
   {
     //Variable Declaration
     string numberVal;
     int number, result;
     
     //User Input
     Console.Write("Enter Number of terms whose cube sum needs to be calculated:");
     numberVal = Console.ReadLine();
     number = Convert.ToInt32(numberVal);
     
     //Cube Sum of Natural Number Logic
     result = ((number * (number + 1)) / 2) * ((number * (number + 1)) / 2);
     
     //Print Result
     Console.WriteLine($"Cube Sum of {number} natural number is: {result}");
     
     Console.Read();
   }
 }
}

Output

Enter Number of terms whose cube sum needs to be calculated:10
Cube Sum of 10 natural number is: 3025