Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
674 B
13
Indexable
#include <stdio.h>

void get_array(int a[], int *n)
{
    int temp, keep_reading = 1;
    
    printf("Enter your array (0 to stop):\n");
    *n = 0;
    do
    {
        scanf("%d", &temp);
        if (temp != 0)
        {
            a[*n] = temp;
            *n += 1;
        }
        else
            keep_reading = 0;
    } while (keep_reading);
}

int main ()
{
    int a[100];
    int n, i, ans1, ans2;
    
    get_array(a, &n);
    
    ans1 = 0;
    ans2 = 0;
    
    for (i = 0; i < n; i++)
        if (a[i] % 5 == 0)
            ans1++;
        else if (a[i] < 0 && a[i]%2 == 0)
            ans2++;
            
    printf("%d %d", ans1, ans2);
    return 0;
}