0
what is the script on how to calculate the average of numbers from 0 to 100 inclusive
3 Antworten
+ 1
var sum,a,ave;
sum=0;
for(a=0;a<100;++a){sum=sum+a}
ave=sum/100
0
var n = 100;
document.write("Average of numbers from 0 to " + n + ": " + n/2);
0
var a,sum=0;
for(a=1;a<=100;a++)
{
sum+=a; // sum=sum+a
}
sum/=100; //sum=sum / 100
document.write(sum);