C Language
#include<stdio.h> #include<conio.h> void main( ) { int n, i, s = 0, a; clrscr( ); printf("Enter n = "); scanf("%d", & n); for (i = 1; i < = n; i++) { s = s + i; } a = s/n; printf("Average = %d, s); getch( ); } /*OUTPUT*/ Enter n = 5 Average = 3