Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program passes an array of six integers (10, 5, 15, 20, 30, and 25) into

ID: 3885902 • Letter: W

Question

Write a program passes an array of six integers (10, 5, 15, 20, 30, and 25) into three functions called multiple_of_ten(), half(), and sum_and_average(). The multiple_of_ten function should accept a copy of each value in the array and determine whether the value is a multiple of 10. The half function should accept the array and output the first three integers in the array. The sum_and_average function should accept the array and compute the sum and average of all of six integers.

Tasks for this assignment:

1) Conceptualizethisproblemandextractoutthepotentialdatastructuresand paradigms that would be used to solve this problem.

2) Write pseudocode that demonstrate the procedures that could be used to write a program for solving this problem.

3) Develop the actual program using C++ syntax and semantics.

Explanation / Answer

#include<iostream>
#include<string>
using namespace std;


void multiple_of_ten(int arr[], int size)
{
   int i=0;
   while(i<size)
   {
       if(arr[i]%10==0)
       {
           cout<<"Element "<<i+1 <<" value "<<arr[i]<<" is Multiple of 10"<<endl;
       }
       i++;
   }
   cout<<endl;
}

void half(int arr[],int size)
{
   int half=size/2;
   int i=0;
   cout<<"The first three elements are"<<endl;
   while(i<half)
   {
       cout<<arr[i]<<endl;
       i++;
   }
   cout<<endl;
}

void sum_and_average(int arr[],int size)
{
   int sum=0;
   double average=0;
   int i=0;
   while(i<size)
   {
       sum=sum+arr[i];
       i++;
   }
   average=sum/6.0;
   cout<<"sum of the array is "<<sum<<endl;
   cout<<"Average of the array is "<<average<<endl;
}
int main ()
{
   int arry[]={10,5,15,20,30,25};
   int size=6;

   multiple_of_ten(arry,size);
   half(arry,size);
   sum_and_average   (arry,size);
    return 0;
}

OUTPUT:

Element 1 value 10 is Multiple of 10
Element 4 value 20 is Multiple of 10
Element 5 value 30 is Multiple of 10

The first three elements are
10
5
15

sum of the array is 105
Average of the array is 17.5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote