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

C++ PROGRAM! 1.) Please complete the exercises below. a) Create an int array to

ID: 3813405 • Letter: C

Question

C++ PROGRAM!

1.) Please complete the exercises below.

a) Create an int array to store 10 values. Write a simple loop to initialize the array elements with the values 2, 4, ... 20

Write another loop to print all the elements of the array in reverse.

b) Create a char array to store 26 values. Write a simple loop to initialize the array elements with the values a, b, c ... z

Write another loop to print all the vowels and the index where each is stored. e.g.: a at index 0

c) Implement a function named avg that takes an int array and its length as parameters and returns the average of the values in the array.

Call the function with a sample array and print the average value.

d) Implement a function named min_max that takes an int array, its length, and two int parameters min and max. The function sets min to the min value in the array and max to the max value in the array. The function returns nothing. Call the function and print the min and max values found.

e) Implement a function named getScores that takes an int array, its length, and an int parameter scores_entered. The function repeatedly asks the user to enter scores until the user enters -1 or the array capacity has been reached. The function stores the scores entered in the array and sets the scores_entered parameter to the number of scores entered by the user. The function returns nothing.

f) Implement a function named scoreStatistics that gets up to 100 scores from the user and prints the min, the max and the average score. The function takes no parameters and returns nothing. It does all its work by relying on the functions in 3, 4, and 5 implemented above.

g) Write a simple program that creates a multiplication table (10x10 two dimensional array). Once the table has been populated with values write two loops that print the values along the two diagonals of the the multiplication table.

Explanation / Answer

HI, I have answered first four part of the questions.

Please repost others part in separate post.

Please let me know in case of any issue in first 4 part.

#include <iostream>
using namespace std;

//c

double avg(int arr[], int size){

   double sum = 0;
   for(int i=0; i<size; i++)
       sum = sum + arr[i];

   return sum/size;
}

//d

void min_max(int arr[], int size, int &max, int &min){

   // initializing min and max with first element
   max = arr[0];
   min = arr[0];

   for(int i=1; i<size; i++){

       if(max < arr[i])
           max = arr[i];

       if(min > arr[i])
           min = arr[i];
   }
}


int main(){


   //a
   // declaring an array of size 10
   int arr[10];

   // initializing with values
   int value = 2;
   for(int i=0; i<10; i++){
       arr[i] = value;
       value = value + 2;
   }

   //b
   // creating an character array
   char charArr[26];
   char c = 'a';
   for(int i=0; i<26; i++){
       charArr[i] = c;
       c = c + 1;
   }


   return 0;
}

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