Write a program to find out whether a given integer is present in an array or not.

Suman Barik
0

 public class MyClass {

    public static void main(String args[]) {

         float [] marks = {45.7f, 67.8f, 63.4f, 99.2f, 100.0f};

        float num = 45.57f;

        boolean isInArray = false;

        for(float element:marks){

            if(num==element){

                isInArray = true;

                break;

            }

        }

        if(isInArray){

            System.out.println("The value is present in the array");

        }

        else{

            System.out.println("The value is not present in the array");

        }

    }

}

Post a Comment

0Comments
Post a Comment (0)