07 August 2018

C/C++ Program to find sum of cubes of n natural numbers

//Program to find sum of cubes of n natural numbers
#include<iostream>
using namespace std;
int main()
{
    int n,sum;
    cout<<"\n enter upto which number you want to find sum of cubes:";
    cin>>n;
    sum=n*(n+1)/2;//using sum of n naturals formula
    sum=sum*sum;
    cout<<"\n sum of "<<n<<" natural numbers is : "<<sum<<endl;
return 0;
}
Similar program(s) :
C++ Program to find sum of squares of n natural numbers
C++ Program to find sum of n natural numbers

No comments:

Post a Comment

To convert from Upper case to lowercase(A to a)

//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...