![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C Program for the cube sum of first n natural numbers?
The cube sum of first n natural numbers is the program to add cubes of all natural numbers up to n. It is sum of series 1^3 + 2^3 + …. + n^3 that is sum of cube of n natural numbers.
Input:6 Output:441
Explanation
1^3 + 2^3 + 3^3 + 4^3 + 5^3 + 63 = 441
Using For loop to increase the no. and cubing it and taking sum of them.
Example
#include <iostream> using namespace std; int main() { int n = 6; int sum = 0; for (int i = 1; i <= n; i++) { sum += i * i * i; } printf(“%d”, sum); return 0; }
Advertisements