Answer to Question #293173 in C for harsh

Question #293173

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.


1
Expert's answer
2022-02-02T11:48:29-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS