code by what is given and try to make the output look like the sample that is sh
ID: 3694311 • Letter: C
Question
code by what is given and try to make the output look like the sample that is shown in the quesiton. Please use only one D array not 2 D array. Code in C not C++
1. (100 pts) Write a program that computes the number of elements in an array divisible by a User specified number. Declare an integer array of size 7 and read the array elements from the user. by k. Consider the following example. 1223431 0 1 2 34 5 6 3 elements in this array are divisible by 2 (2,2,4)). Sample execution of the program for this array is given below Enter 7 numbers 1 2 2 3 4 31 Enter k 3 elements are divisible by 2 For this assignment, YOU MUST: .Store the User input into an array of size-7 Create functions for o int divisible(ant a, int b) The finction divisible0 returns 1 o int divisible (int a, int b) - The function divisible) returns 1 if a is divisible by b and 0 otherwise. o int count (int data[],int n, int k) - The function countO fiunction divisible inside the function count0.)Explanation / Answer
#include<stdio.h>
void main()
{
int arr[7],i,k,x=0,s;
printf(“ Enter the elements of the array.”);
for(i=0;i<7;i++)
{
scanf(“%d”,&arr[i]);
}
printf(“ Enter the elements of the array.”);
scanf(“%d”,&k);
s=count(arr,7,k);
printf(“ There are %d number of elements in the array which are divisible by k.”,s);
}
int count(int data[],int n,int p)
{
for(i=0;i<7;i++)
{
divisible(data[i],p);
x++;
}
return x;
}
int divisible(int a,int b)
{
if (a%b==0)
{
return 1;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.