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