adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to find the separately sum of odd and even numbers in given numbers in array.

Write a program in C to find the separately sum of odd and even numbers in given numbers in array.


#include<stdio.h>
#include<conio.h>
  void main()
   {
   int a[50],i,n,even_sum=0,odd_sum=0;
   clrscr();
   printf("Enter a number you want to insert:-");
   scanf("%d",&n);
   printf("Enter %d numbers:-",n);
   for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    } 
    for(i=0;i<n;i++)
     if(a[i]%2==0)
     even_sum=even_sum+a[i];
     else
      odd_sum=odd_sum+a[i];
     printf("even sum =%d",even_sum);
     printf("\nodd sum=%d",odd_sum);
     getch();
     }
Output:-

Related programs:
  1.    Write a program in C to sort array elements in ascending  order.
  2.    Write a program in C to check that a number entered by the user is Armstrong number.
  3.    Write a program to print 1 to 100 numbers using while loop.
  4.     Write a program in C to find greatest prime number less than a given positive number. 

Post a Comment

0 Comments