PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY
PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY
I/P:
5
1 0 2 0 0
O/P:
3
This program explains how many zeros present in the zero
PROGRAM:
import java.util.*;
public class ZeroCount {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int iNum=sc.nextInt();
int arr[]=new int[iNum];
for(int i=0;i<iNum;i++)
{
arr[i]=sc.nextInt();
}
int count=0;
for(int i=0;i<iNum;i++)
{
if(arr[i]==0)
{
count++;
}
}
System.out.println(count);
}
}
// 5
// 1 1 1 0 0
// 2
Comments
Post a Comment