Write a java programe to find out the given no. is present in array or not .

 public class Nilesh{

    public static void main (String args []){

        int num=4;

        

        int []marks={1,2,3,4,5};

        boolean isInArray=false;

        for (int element  : marks){

            if (element==num){

                isInArray=true;

                break;}}

            

            if (isInArray){

                    System.out.println("Number is present in these array");}

            else {

                    System.out.println("Number is not present in these array");}

        }

        }

Comments

Popular posts from this blog

Create an array of 5 floats and calculate their sum in java .