Skip to content
Home » C Programs » Odd or Even Program in C Using Array

Odd or Even Program in C Using Array

Simple odd or even in c using array for beginners to execute the odd or even number using array method in c programming language.

Array Definition in C

An array is a collection of data items of the same type stored in contiguous memory locations. Arrays are a derived data type in the C programming language that can hold primitive data types like int, char, double, float, and so on. A container object that holds a fixed number of values of a single type is called an array. 

The length of an array is determined at the time of its creation. Its length is fixed after it is created. Array: a collection of a certain number of components, all of which have the same data type. 

The components of a one-dimensional array are organised in a list format. The term “multi-dimensional array” refers to an array in which the components are organised in a tabular format. Using the array statement we have executed the odd or even in c

Odd and Even Number Definition

A number that can be divided into two equal groups is called an even number. A number that cannot be divided into two equal groups is called an odd number. Even numbers, regardless of how many digits they have, end in 2, 4, 6, 8, or zero.

Odd or Even in C

//odd or even in c
#include <stdio.h>
void main()
{
int arr[100], i, num;
printf("Enter Size of arr \n");
scanf("%d", &num);
printf("arr Elements \n");
for (i = 0; i < num; i++) 
{
scanf("%d", &arr[i]);
}
printf("Even Numbers in arr");
for (i = 0; i < num; i++) 
{
if (arr[i] % 2 == 0) 
{
printf("%d \t", arr[i]);
}
}
printf("\n Odd Numbers in arr");
for (i = 0; i < num; i++) 
{
if (arr[i] % 2 != 0) 
{
printf("%d \t", arr[i]);
}
}
}

Odd or Even in C With Output:

Enter Size of arr
5
arr Elements
34
56
78
34
45
Even Numbers in arr 34 56 78 34
Odd Numbers in arr 45