EXERCİSE 4/ lab sheet 7 (arrays)

PHOTO EMBED

Mon Dec 12 2022 18:09:25 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif

#include <stdio.h>
#include <stdlib.h>
/*Exercise 4
Write a C code that will ask the user to enter 10 numbers, store them in an array. Then count the number of even and odd numbers in the array. And print the result on the screen.*/

//total even number are :::::::::
//total odd number are :::::::::::

int main() {
    int arr[10];
    int i;
    int evenCount=0, oddCount=0;
    for(i=0;i<=9;i++)
    {
        printf("Please Enter Element %d: ",i+1);
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<=9;i++)
    {
        if(arr[i]%2==0)
        {
            evenCount++;
        }
    else
        {
            oddCount++;
        }
    }
    printf("total even number are= %d\n",evenCount);
    printf("\ntotal odd number are= %d\n",oddCount);
    
    return 0;
}
content_copyCOPY