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

3 Responses to “Program to accept five numbers and display the sum of even numbers and product of odd numbers”

  1. Its like you scan my mind! You appear to grasp therefore much concerning this, such as you wrote the book in it or something. I suppose that you may do with some pics to drive the message home a very little bit, however alternative than that, this is often nice blog. A great read.

    Reply

Leave a Reply