Computer Science, asked by pihu16, 1 year ago

Write a program in java to accept 5 numbers from the user in an array and print the first and the last number of the array.

Answers

Answered by Anonymous
2
import java.io.*;
class Five_numbers
{  
   public static void main()throws IOException
   {
     int a[]=new int[5];
DataInputStream di=new DataInputStream(System.in);
System.out.println("enter 5 numbers in array");
for(int i=0;i<5;i++)
{
a=Integer.parseInt(di.readLine());
}
System.out.println("FIRST NUMBER"+a[0]);
System.out.println("LAST NUMBER"+a[4]);
}
}

Similar questions