#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,even[50],odd[50],sum=0,prod=1;
clrscr();
printf("Enter 10 elements:");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("\nEven nos are:");
for(i=0;i<10;i++)
{
if(a[i]%2==0)
{
even[i]=a[i];
printf("%d\t",even[i]);
sum=sum+even[i];
}
}
printf("\nodd nos are:");
for(i=0;i<10;i++)
{
if(a[i]%2!=0)
{
odd[i]=a[i];
printf("%d\t",odd[i]);
prod=prod*odd[i];
}
}
printf("\nSum of even nos is %d",sum);
printf("\nproduct of odd numbers is %d",prod);
getch();
}
#include<conio.h>
void main()
{
int a[50],i,even[50],odd[50],sum=0,prod=1;
clrscr();
printf("Enter 10 elements:");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("\nEven nos are:");
for(i=0;i<10;i++)
{
if(a[i]%2==0)
{
even[i]=a[i];
printf("%d\t",even[i]);
sum=sum+even[i];
}
}
printf("\nodd nos are:");
for(i=0;i<10;i++)
{
if(a[i]%2!=0)
{
odd[i]=a[i];
printf("%d\t",odd[i]);
prod=prod*odd[i];
}
}
printf("\nSum of even nos is %d",sum);
printf("\nproduct of odd numbers is %d",prod);
getch();
}
C++ Program Even and Odd Elements in Array
ReplyDeletenice ji
Visit nice example Even odd logic
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks !!
ReplyDeletePositive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Eyyaa
ReplyDelete