should display the message "Number of integers divisible by 4 is 4". number of integers in the array that are divisible by 4. That is, your loop and negative integers. Write a loop statement to count and display the 5) Consider the array called myArray declared below that contains positive mt myArray]=(1,3.9.91.40,4,-5,100,20,-23); array are changed.
Solve the attachment
Note:
Programming language is missing in the question. So we will answer this program in C++. If you want this program to be executed in some other programming language, kindly repost the question with a specific programming language.
Program:
#include <iostream>
using namespace std;
int main()
{
//Initialize the array with given values
int myArray[]={1,3,9,91,40,4,-5,100,20,-23};
//Compute the array size
int size=sizeof(myArray)/sizeof(myArray[0]);
int countNumbers=0;
/*Create a loop to count and display the number
of integers in the array that are divisible by 4*/
for(int ind=0;ind<size;ind++)
{
//check whether the integer in the array is divisible by 4
if(myArray[ind]%4==0)
//Increment the count
countNumbers++;
if(ind==size-1)
//Display the output
cout<<"Number of integers divisible by 4 is "<<countNumbers;
}
return 0;
}
Step by step
Solved in 3 steps with 2 images