Answer to Question #182294 in C++ for Banele

Question #182294

write a statement to do the following

1 change 19 to 108

2 display the array on reverse

3 find the min and max value and display


1
Expert's answer
2021-04-16T12:00:42-0400
#include <iostream>
#include <random>
#include <ctime>


using namespace std;


int main()
{
	srand(time(0));
	int A[108];
	for (int i = 0; i < 108; i++)
	{
		A[i] = rand() % 5000;
	}
	cout << "Array in right order: ";
	for (int i = 0; i < 108; i++)
	{
		cout << A[i] << " ";
	}
	cout << endl << endl << "Array in reverse order: ";
	for (int i = 107; i >= 0; i--)
	{
		cout << A[i] << " ";
	}
	int min = A[0];
	int max = A[0];
	for (int i = 1; i < 108; i++)
	{
		if (A[i] > max) max = A[i];
		if (A[i] < min) min = A[i];
	}
	cout << endl << endl;
	cout << "Max value is: " << max << endl;
	cout << "Min value is: " << min << endl;
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS