• Register
754 points
7 2

Overview:

Today we will count even and odd numbers in our program. You will be given an array. You will count even and odd numbers in it.

Even & odd in c++ code:

#include <stdio.h>
    void main()
    {
 
        int array[80], i, num;
        printf("Enter the size of an array \n");
 
        scanf("%d", &num);
        printf("Enter the elements of the array \n");
 
        for (i = 0; i < num; i++) 
        {
            scanf("%d", &array[i]);
        }
 
        printf("Even numbers in the array are - ");
        for (i = 0; i < num; i++) 
        {
            if (array[i] % 2 == 0) 
            {
                printf("%d \t", array[i]);
            }
        }
 
        printf("\n Odd numbers in the array are -");
        for (i = 0; i < num; i++) 
        {
            if (array[i] % 2 != 0) 
            {
                printf("%d \t", array[i]);
            }
        }
 
    }

Example even & odd:

Example flowchart: