Thursday, 31 May 2012

average of numbers using array


class Averagedemo{
public static void main(String args[]) {
double nums[] = {31, 2, 1, 11, 10};
double result = 0;
int i;
for(i=0; i<5; i++)
result = result + nums[i];
System.out.println("Average is " + result / 5);
}
}

No comments:

Post a Comment