0.
Write a program to input 10 integers and display the largest even integer. In case there is no even
integer, it should print "No even integer found.
Answers
Answer:
JAVA CODE :
import java.util.*;
class largest_integer
{
public void main()
{
Scanner sc=new Scanner(System.in);
int a[]=new int[10];
System.out.println("Enter 10 numbers");
for(int i=0;i<10;i++)
{
a[i]=sc.nextInt();
}
int max=0;
for(int i=0;i<10;i++)
{
if(a[i]>max)
{
max=a[i];
}
}
System.out.println("The largest integer is :"+a[i]);
}
}
----------------------------------------------------------------------------
OUTPUT :
Enter 10 numbers
1
2
3
4
5
6
7
8
9
10
The largest integer is :10
Hope it helps
Answer:
I am only writing the logic okay..
void largest_even(int arr[]){
int i = 0, l, present = 0;
for(I = 0; I < 10; i++){
if (are[I] % 2 == 0){
present ++;
if (present > 1 && l < are [I] ) l = are [I];
else l = are[I];
}
}
if(present)
cout << l << endl;
else
cout << " No even numbers found ";
}
Explanation:
first you take input of 10 integers and the store them in an array
and then pass them to this function and you will get the answer