Computer Science, asked by vibhasingh8, 7 months ago

WAP to return sum of squares of numbers in given range (1-n).
public class Solution{
public static int sum(int n)
{
//write your code here
}
}​

Answers

Answered by Abhinab08
0

Explanation:

// CPP program to calculate

// 1^2+2^2+3^2+...

#include <iostream>

using namespace std;

// Function to calculate sum

int summation(int n)

{

int sum = 0;

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

sum += (i * i);

return sum;

}

// Driver code

int main()

{

int n = 2;

cout << summation(n);

return 0;

}

Answered by ArpitMishra506
2

You can try this one of these if you want to make the program in JAVA.

.

.

.

HOPE IT HELPS YOU

.

.

.

PLEASE MARK ME AS BRAINLIEST AND FOLLOW ME TOO.

Attachments:
Similar questions