Question: Write a C++ program to : 1. Create an integer array of size 20 Assign int values using loops such that the first element is

Write a C++ program to :

1. Create an integer array of size 20

Assign int values using loops such that the first element is 3 and every element after that is the determined by the following formula:

a[i] = a[i-1] + (3*i) if a[i-1] is an even number

a[i] = a[i-1] - (2*i) if a[i-1] is an odd number

Print array elements with each element separated by a space

Compute and print the following (with formats given in double quotes):

a. average of all array elements - "Average : "(value)

b. maximum element - "Maximum value : "(value)

c. minimum element - "Minimum value : "(value)

d. number of elements divisible by 5 - "Count of numbers divisible by 5 : "(value)

Ensure every statement is printed on a new line.

#include #include using namespace std;

int main() { //declare array //assign values to array //print array elements //compute and print average //compute and print maximum value //compute and print minimum value //compute and print count of array elements divisible by 5 return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!