Create an array Create an array populated with the integer v

Create an array Create an array populated with the integer values 1 through 20. checkDivisibleBy3 method Create a function called checkDivisibleBy3. This function will receive as a parameter an array of integers. Using the is Divisible function created in Part One, count how many of the elements in the array are divisible by 3. Display the count with a message like: \"There were 6 elements that were divisible by 3\". Call this function from the main function using the array you created in Part Two.

Solution

#include<iostream>

#include<conio.h>

using namespace std;

//function declaration

CheckDivisibleBy3(int arr1[ ],int size);

//function defination

CheckDivisibleBy3(int arr1[ ],int size)

{

int i,count=0;

//check the condition by iteration through all numbers

for(i=0;i<size;i++)

{

//increment count if number divisible by 3

if((arr[i]%3)==NULL)

{

count++;

}

}

//display count

cout<<\" There were\" <<count<<\"elements that were divisible by 3\"<<endl;

}

void main()

{

int arr[20],n=20,i;

cout<<\"populating the array elements fr\ \";

for(i=0;i<n;i++)

{

//read elements into array from 1 to 20 automatically

arr[i]=(i+1);

}

//fuction call

CheckDivisibleBy3(arr,n);

getch();

}

 Create an array Create an array populated with the integer values 1 through 20. checkDivisibleBy3 method Create a function called checkDivisibleBy3. This funct
 Create an array Create an array populated with the integer values 1 through 20. checkDivisibleBy3 method Create a function called checkDivisibleBy3. This funct

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site