Sum of first n even numbers | C ++ implementation to find sum of first n even numbers ; function to find sum of first n even numbers ; required sum ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; int evenSum ( int n ) { return ( n * ( n + 1 ) ) ; } int main ( ) { int n = 20 ; cout << " Sum ▁ of ▁ first ▁ " << n << " ▁ Even ▁ numbers ▁ is : ▁ " << evenSum ( n ) ; return 0 ; }