5
Arrays Single Dimensional Array: Syntax: Int marks[]={50,60,55,67,70}; Program: Write a program which accepts the marks of a student into a ID array from the keyboard and finds total marks and percentage. Import java.io.*; Class Arr2 { Public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); InputStreamReader(System.in)); System.out.print(“How many subjects?”); Int n=Integer.parseInt(br.readLine()); Int[] marks=new int[n]; for(int i=0;i<n;i++) { System.out.println(“Enter marks:”); marks[i]=Integer.parseInt(br.readLine()); }

Arrays

Embed Size (px)

DESCRIPTION

java related arrays with examples

Citation preview

ArraysSingle Dimensional Array:Syntax:Int marks[]={50,60,55,67,70};Program:Write a program which accepts the marks of a student into a ID array from the keyboard and finds total marks and percentage.Import java.io.*;Class Arr2{Public static void main(String args[])throws IOException{BufferedReader br=new BufferedReader(new InputStreamReader(System.in));InputStreamReader(System.in));System.out.print(How many subjects?);Int n=Integer.parseInt(br.readLine());Int[] marks=new int[n];for(int i=0;i