Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

4. Describe some cultural differences in the notion of friendship.

Answered: 1 week ago