text: Average of odd numbers till a given odd number | C # Program to find average of odd numbers till a given odd number . ; Function to calculate the average of odd numbers ; driver function
code: using System ; class GFG { static int averageOdd ( int n ) { if ( n % 2 == 0 ) { Console . Write ( " Invalid ▁ Input " ) ; return - 1 ; } return ( n + 1 ) / 2 ; } public static void Main ( ) { int n = 15 ; Console . Write ( averageOdd ( n ) ) ; } }