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()
{
int n = 10, x = 7, y = 2, number = 0;
int a[10] = {};
for (int i = 0; i != 10; ++i)
{
a[i] = i;
if (a[i] <= x && a[i] % y == 0)
{
number += 1;
}
}
printf("Number of such integers is %d\n", number);
return 0;
}
Comments
Leave a comment