Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Wednesday

JAVA PROGRAMMING TUTORIAL 28: SUMMATION OF ELEMENTS OF ARRAY

public class HackDefence{

public static void main(String[]args){

int sum = 0;

int array[] = {78,95,34,76};

for(int counter = 0; counter<array.length;counter++){ //array.length gives  length of  array

                  sum+=array[counter];

                }

                  System.out.println("Sum of elemnets of array:" + sum);

             }

    }

OUTPUT:


1 comment:

Related Posts Plugin for WordPress, Blogger...