Find the average of first N natural numbers | CPP Program to find the Average of first n natural numbers ; Return the average of first n natural numbers ; Driven Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; float avgOfFirstN ( int n ) { return ( float ) ( 1 + n ) / 2 ; } int main ( ) { int n = 20 ; cout << avgOfFirstN ( n ) << endl ; return 0 ; }