Average of Squares of Natural Numbers | C ++ program to calculate 1 ^ 2 + 2 ^ 2 + 3 ^ 2 + ... average of square number ; Function to calculate average of squares ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float AvgofSquareN ( int n ) { float sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum / n ; } int main ( ) { int n = 2 ; cout << AvgofSquareN ( n ) ; return 0 ; }