Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS 112 - Programming Fundamentals 1 (Lec) Date: September 14, 2012 - Array.

Similar presentations


Presentation on theme: "IS 112 - Programming Fundamentals 1 (Lec) Date: September 14, 2012 - Array."— Presentation transcript:

1 IS 112 - Programming Fundamentals 1 (Lec) Date: September 14, 2012 - Array

2 Array An Array is a collection (sequence ) of a fixed number of variables called elements or components, wherein all the elements are of the same data type. dataType [ ] arrayname = new dataType[noElements];

3 The Statement: Declares and creates the array num cosisting of 5 elements. Each elements are acceed as num[0], num[1], num[2], num[3], num[4]. int [ ] num = new int [5];

4 import java.util.Scanner; public class arraydemo1 { public static void main(String[]args) { Scanner keyboard=new Scanner(System.in); int noofEl; System.out.println("How many elements of array: "); noofEl = keyboard.nextInt(); int [] num = new int[noofEl]; int i, sum=0, prod=1, ave=0; System.out.println("Enter "+noofEl+" nos: "); for(i=0;i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/1/42760/slides/slide_4.jpg", "name": "import java.util.Scanner; public class arraydemo1 { public static void main(String[]args) { Scanner keyboard=new Scanner(System.in); int noofEl; System.out.println( How many elements of array: ); noofEl = keyboard.nextInt(); int [] num = new int[noofEl]; int i, sum=0, prod=1, ave=0; System.out.println( Enter +noofEl+ nos: ); for(i=0;i


Download ppt "IS 112 - Programming Fundamentals 1 (Lec) Date: September 14, 2012 - Array."

Similar presentations


Ads by Google