Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
34 views1 page

Count Even Numbers

This Java code takes user input of array size and elements, counts even numbers in the array and displays them along with total even count.

Uploaded by

vskkavitha786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Count Even Numbers

This Java code takes user input of array size and elements, counts even numbers in the array and displays them along with total even count.

Uploaded by

vskkavitha786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;

class CountEven1
{

public static void main(String[] args)


{
int Size, i, evenCount = 0;
Scanner sc = new Scanner(System.in);

System.out.print(" Please Enter Number of elements in an array : ");


Size = sc.nextInt();

int [] a = new int[Size];

System.out.print(" Please Enter " + Size + " elements of an Array :


");
for (i = 0; i < Size; i++)
{
a[i] = sc.nextInt();
}
System.out.print("\n List of Even Numbers in this Array are :");
for(i = 0; i < Size; i++)
{
if(a[i] % 2 == 0)
{
System.out.print(a[i] +" ");
evenCount++;
}
}
System.out.println("\n Total Number of Even Numbers in this Array = " +
evenCount);
}
}

You might also like