text: Average of even numbers till a given even number | Program to find average of even numbers till a given even nend umber . ; Function to calculate the average of even numbers ; driver function
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int averageEven ( int n ) { if ( n % 2 != 0 ) { cout << " Invalid ▁ Input " ; return -1 ; } return ( n + 2 ) / 2 ; } int main ( ) { int n = 16 ; cout << averageEven ( n ) << endl ; return 0 ; }