click on this link......

LinkGrand.com

Tuesday 22 January 2013

To find sumof even numbers and product of odd numbers in an array


#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();
}

To find sumof even numbers and product of odd numbers in an array

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Positive 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