Answer to Question #285771 in C++ for Sara

Question #285771

Write a C++ program that defines an integer array of size 18, the program asks the user to fill the array from the keyboard. After filling the array, the function prints all values that are divisible by 3 and less than the average


1
Expert's answer
2022-01-09T02:20:28-0500
using namespace std;


/*
	Write a C++ program that defines an integer array of size 18, 
	the program asks the user to fill the array from the keyboard. 
	After filling the array, the function prints all values that are divisible by 3 and less than the average
*/


#define ARR_SIZE	18
int main()
{
	int r,n;
	int Array[ARR_SIZE];
	float Avg;
	for(n=0;n<ARR_SIZE;n++) Array[n] = 0;
	
	n=0;
	Avg = 0;
	while(n<ARR_SIZE)
	{
		cout<<"\nEnter =Array Element-"<<n+1<<": "; cin>>Array[n]; 
		Avg = Avg+Array[n];
		n++;
	}
	Avg = Avg/ARR_SIZE;
	cout<<"\n\n";
	for(n=0;n<ARR_SIZE;n++)		
	{
		if(Array[n]<Avg && Array[n]%3==0) cout<<"\nArray element les than Avg. (="<<Avg<<") or divisible by 3 = "<<Array[n];
	}
	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