List odd and even number from given array

Program:
#include<stdio.h>
void check(int num);

int main()
{
    int arr[5]={1,2,3,4,5};
    int  i;
    for(i=0;i<5;i++)
    {
        //scanf("%d",&arr[i]);
        check(arr[i]); 
    }
}
    void check(int num )
    {
        if(num%2==0)
        {
            printf("The array elment %d is even\n",num);
        }
        else
        {
            printf("The array elment %d is odd\n",num);
        }
    }

   
Output:

The array elment 3 is odd                                                                                                                                
The array elment 4 is even                                                                                                                               
The array elment 5 is odd

Comments

Popular Posts