Average of first n even natural numbers | C ++ implementation to find Average of sum of first n natural even numbers ; function to find average of sum of first n even numbers ; sum of first n even numbers ; calculating Average ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int avg_of_even_num ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += 2 * i ; return sum / n ; } int main ( ) { int n = 9 ; cout << avg_of_even_num ( n ) ; return 0 ; }