Given an array A of N integers and two integers X and Y, find the number of integers in the array that are both less than or equal to X and divisible by Y
#include <stdio.h>
int main()
{
  const int n = 10;
  const int a[] = {4, 7, 2, -2, 5, 10, 11, 0, 2, 1};
  const int x = 6;
  const int y = 2;
   
  int c = 0;
  for (int i = 0; i < n; i++)
    if (a[i] <= x && a[i] % y == 0)
      c++;
   
  printf("%d", c);
  return 0;
}
Comments