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
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);
}
Comments
Leave a comment