1 2 3 4 5 6 7 8 9
//chapter 6 Ex 2 clc; clear; close; n=40; Sum=n*(n+1)/2; //formula for sum of first n natural numbers avg=Sum/n; mprintf("The required average is %.1f",avg);