Array in java using scanner to accept integer

//using scanner class
import java.util.*;
class ex_7
{
    public static void main(String[]args)
    {
        Scanner sc=new Scanner(System.in);
        int i;
        int n[]=new int[10];
       
        for(i=0;i<10;i++)
        {
            System.out.println("Enter the number:"+(i+1)+" :");
            n[i]=sc.nextInt();
        }
        //now displaying the number
        System.out.println("the number are:");
        for(i=0;i<10;i++)
        System.out.print(n[i]+"\t");
    }
}

No comments:

Post a Comment

any problem in any program comment:-

Second largest number in java using ternary operator

 //Largest second number using ternary operator public class Main { public static void main(String[] args) { int a=5,b=6,c=7; int ...