CBSE BOARD XII, asked by farzanafirdauz, 7 months ago

Write a c++ program to input 5 elements and to display it's square.

Answers

Answered by ghorai55
1

Answer:

CPP Program to find sum of square of first n natural numbers

#include <bits/stdc++.h>

using namespace std;

// Return the sum of the square

// of first n natural numbers

int squaresum(int n)

{

// Iterate i from 1 and n

// finding square of i and add to sum.

int sum = 0;

for (int i = 1; i <= n; i++)

sum += (i * i);

return sum;

}

// Driven Program

int main()

{

int n = 4;

cout << squaresum(n) << endl;

return 0;

}

Explanation:

hope it's helpful

Similar questions