Get Adobe Flash player

Saturday, January 14, 2012

Java Program implementing 1D Array

class ArrayProg{
public static void main(String args[]){
int marks[];
marks=new int[5];

int total;
int average;
total=0;
marks[0]=45;
marks[1]=36;
marks[2]=86;
marks[3]=67;
marks[4]=56;

for(i=0;i<5;i++){
total+=marks[i];
}
average=total/5;

System.out.println("Average is : "+average);
}
}


This program will output the following result:



Average is : 58

1 comments:

Dipanwita said...

This is a great blog pots. Will look forward to more such posts. java training in chennai

Post a Comment