Blog

WAP to Find a number Odd or Even using Array in C Programming

WAP to Find a number Odd or Even using Array
In this article we will learn how to write a Program to find odd or even from a list of elements using array in C programming

#include<stdio.h>
void main()
{
	int sumo=0, sume=0, i=0, odd[5], even[5], a=-1, b=-1;
	for(i=4; i<=17;i++)
	{
		if(i%2==0)
		even[++a]=i;
		else
		odd[++b]=i;		
	}
	printf("\n\tEven \t\tOdd");
	for(i=0;i<5;i++)
	{
		printf("\n\t %d \t\t %d",even[i],odd[i]);
		sume=sume+even[i];
		sumo=sumo+odd[i];
	}
	printf("\n\t====================\n");
	printf("Addition :%d %14d", sume,sumo);
	getch();
}

Leave a Reply

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