Tuesday, March 5, 2013

C Language Example # 31 Find out odd and even numbers from Array

C Language Example # 31 Find out odd and even numbers from Array 

* Program will find total number of odd numbers and total number of even numbers from array.

//Written by Latest Technology Guide    
//Title : C Language Example # 
31 Find out odd and even numbers from Array 

#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a[10]={0},i,sum=0,od=0,ev=0;

printf("\n Now Enter Value for Array A : \n");

for(i=0;i<10;i++)
{
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}

for(i=0;i<10;i++)
{
if(a[i]%2==1)
od=od+1;
}
printf("\n\n\t\t : Odd Number is : %d",od);

for(i=0;i<10;i++)
{
if(a[i]%2==0)
ev=ev+1;
}
printf("\n\n\t\t : Even Number is : %d",ev);

getch();
}


Output:

* Program will display total number of odd numbers and total number of even numbers.

--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 31 Find out odd and even numbers from Array 


* Program will create static array.
* Program will scan value from users and will store into array.
* Program will find total number of odd numbers.
* Program will find total number of even numbers.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

2 comments: