C

Write a c program to Print the largest even and odd number from the list?

 To print the largest even and odd number from the input 10 number, in C Program you have to write a code like this.

/* Print the largest even and odd number from the list */
#include<stdio.h>
#include<conio.h>
void main()
{
int i, num, even=0, odd=0;

printf(“\nEnter any ten numbers: “);
for(i=0;i<10;i++)
{ scanf(“%d”,&num);
if (num%2 == 0 && num>even)
even = num;
if( num%2 != 0 && num> odd)
odd = num;
}
printf(“\n Largest even number is = %d”,even);
printf(“\n Largest odd number is = %d”, odd);
getch();
}

run
……………………….

Enter any ten numbers: 15 18 14 20 13 17 21 54 65 34

Largest even number is = 54
Largest odd number is = 65

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.