Program to accept five numbers and display the sum of even numbers and product of odd numbers

Here is the program which accepts five numbers and display the sum of even numbers and product of odd numbers.

#include "conio.h"
#include "stdio.h"

void main()
{
  int n,sum=0,mul=1,i;
  printf("\nEnter numbers :\n");
  for(i=0;i<5;i++)
  {
  scanf("%d",&n);
  if(n%2==0)
    sum=sum+n;
  else
    mul=mul*n;
  }
  printf("\nThe sum of even numbers is : %d",sum);
  printf("\nThe multiplication of odd numbers is : %d",mul);
getch();
}

Output:

Enter numbers :
4
7
18
23
19
 
The sum of even numbers is : 22
The multiplication of odd numbers is : 3059
Chitra
Chitra

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in