0

what is the script on how to calculate the average of numbers from 0 to 100 inclusive

20th Oct 2016, 9:14 AM
kelvo obiorah
kelvo obiorah - avatar
3 Answers
+ 1
var sum,a,ave; sum=0; for(a=0;a<100;++a){sum=sum+a} ave=sum/100
20th Oct 2016, 10:03 AM
pherz
0
var n = 100; document.write("Average of numbers from 0 to " + n + ": " + n/2);
20th Oct 2016, 10:26 AM
Zen
Zen - avatar
0
var a,sum=0; for(a=1;a<=100;a++) { sum+=a; // sum=sum+a } sum/=100; //sum=sum / 100 document.write(sum);
30th Oct 2016, 12:04 PM
Digbose Hazarika
Digbose Hazarika - avatar