Answer to Question #299506 in C for Ajay

Question #299506

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-18T12:50:42-0500


#include<conio.h>
#include<stdio.h>
#include<stdlib.h>




int main(){
	int size;
	int X;
	int Y;
	int i;
	int counter=0;
	int numbers[1000]; 


	printf("Enter the size of the array: ");
	scanf("%d",&size);
	for(i=0;i<size;i++){
		printf("Enter the number %d: ",(i+1));
		scanf("%d",&numbers[i]);
	}
	printf("Enter X: ");
	scanf("%d",&X);
	printf("Enter Y: ");
	scanf("%d",&Y);
	for (i = 0; i < size; i++) {
		if (numbers[i] <= X && numbers[i] % Y == 0) {
			counter++;
		}
	}


	printf("The number of integers in the array that are both less than or equal to %d and divisible by %d: %d\n",X,Y,counter);






	getchar();
	getchar();


	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