C Program to Find Largest Odd Number from Array
/*
Write a Program to Find largest odd number from given 1-D Array.
*/
#include <stdio.h>
int main(void)
{
int a[10],i,n=10,max=0,j=0;
for(i=0;i<n;i++)
{
printf("Enter Value at a[%d] : ",i);
scanf("%d",&a[i]);
if(a[i]%2==1)
{
if(j==0)
{
max=a[i];
j++;
}
else
{
if(max<a[i])
{
max=a[i];
}
}
}
}
if(j==0)
{
printf("There is no Odd Value in Array");
}
else
{
printf(" Largest Odd value in Array is : %d",max);
}
return 0;
}
Write a Program to Find largest odd number from given 1-D Array.
*/
#include <stdio.h>
int main(void)
{
int a[10],i,n=10,max=0,j=0;
for(i=0;i<n;i++)
{
printf("Enter Value at a[%d] : ",i);
scanf("%d",&a[i]);
if(a[i]%2==1)
{
if(j==0)
{
max=a[i];
j++;
}
else
{
if(max<a[i])
{
max=a[i];
}
}
}
}
if(j==0)
{
printf("There is no Odd Value in Array");
}
else
{
printf(" Largest Odd value in Array is : %d",max);
}
return 0;
}
Comments
Post a Comment