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

Assigmnemt due at 7 pm ET today. Write and submit a complete .cpp program that d

ID: 3691497 • Letter: A

Question

Assigmnemt due at 7 pm ET today.

Write and submit a complete .cpp program that does the following in C++ language:

Part 1: Create an array of integers with a capacity of 6, each element of the array must be filled with a random 2 digit positive number. Print this array.

Part 2: Compute x as the average of the array, then print it.

Part 3: Print out all the entries that are greater than the Average.

Part 4: Compute y as the average of all the entries that were greater than x (from part 3).

Part 5: Compute how many times the digit 6 appears in the array and print the result. (You can use recursion or loops; recursion is easier)

Explanation / Answer

#include <iostream>
#include<cstdlib>
#include<ctime>
using namespace std;

int main() {
   // your code goes here
   srand (time(NULL));
int a[6],count=0;
double sum=0,y,sum1=0;
for(int i=0;i<6;i++)a[i] = (rand()%90)+10;
for(int i=0;i<6;i++)cout<<a[i]<<' ';
cout<<endl;
  
for(int i=0;i<6;i++)
{
sum += a[i];
}
y=sum/6;
cout<<"Average is "<<y<<endl;

for(int i=0;i<6;i++)
{
if(a[i]>y)
{
cout<<a[i]<<' ';
sum1 += a[i];
count++;
}
}
cout<<endl;
cout<<"The average of all numbers greater than mean is "<<sum1/count<<endl;
  
int c=0;
for(int i=0;i<6;i++)
{
int temp = a[i];
if(temp%10==6)c++;
temp = temp/10;
if(temp%10==6)c++;
}
cout<<"The number of timess 6 appears is "<<c<<endl;
   return 0;
}