Explain the looping process used in this C++ code #include using namespace std; int main() { int _arrSize, Ave; cout << "Enter Array Size: "; cin >> _arrSize; cout << "Array Size : " << _arrSize << endl; int a[_arrSize]; cout << "\nEnter values to be used: \n"; for (int i = 0; i < _arrSize; i++) { cin >> a[i]; } cout << "The entered values are: " << endl; for (int i = 0; i < _arrSize; i++) { cout << a[i] << endl; } cout << "\nPlease choose from the following options: " << endl; cout << "1. Get the sum of all the array elements" << endl; cout << "2. Sort the numbers from largest to smallest" << endl; cout << "3. Sort the numbers from smallest to largest" << endl; cout << "4. Get the average of the array elements.\n" << endl; int _sum = 0; int x, temp; cout<<"Enter the number of your choice: "; cin >> x; cout << "\nYou chose option " << x << endl; if (x == 1) { for (int i = 0; i < _arrSize; i++) _sum += a[i]; cout << "The Sum of the elements is: " << _sum; } if (x == 2) { for (int i = 0; i < _arrSize; i++) { for (int j = i+1; j < _arrSize; j++) { if (a[i] < a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } cout << "The number from largest to smallest: \n"; for (int i = 0; i < _arrSize; i++) { cout << " "; cout << a[i]; cout << "\n"; } } if (x == 3) { for (int i = 0; i < _arrSize; i++) { for (int j = i+1; j < _arrSize; j++) { if (a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } cout << "The number from smallest to largest: \n"; for (int i = 0; i < _arrSize; i++) { cout << " "; cout << a[i]; cout << "\n"; } } if (x == 4) { for (int i = 0; i < _arrSize; i++) _sum += a[i]; Ave = _sum/_arrSize; cout << "Average of the elements: " << Ave; } return 0; }
Explain the looping process used in this C++ code
#include <iostream>
using namespace std;
int main()
{
int _arrSize, Ave;
cout << "Enter Array Size: ";
cin >> _arrSize;
cout << "Array Size : " << _arrSize << endl;
int a[_arrSize];
cout << "\nEnter values to be used: \n";
for (int i = 0; i < _arrSize; i++)
{
cin >> a[i];
}
cout << "The entered values are: " << endl;
for (int i = 0; i < _arrSize; i++)
{
cout << a[i] << endl;
}
cout << "\nPlease choose from the following options: " << endl;
cout << "1. Get the sum of all the array elements" << endl;
cout << "2. Sort the numbers from largest to smallest" << endl;
cout << "3. Sort the numbers from smallest to largest" << endl;
cout << "4. Get the average of the array elements.\n" << endl;
int _sum = 0;
int x, temp;
cout<<"Enter the number of your choice: ";
cin >> x;
cout << "\nYou chose option " << x << endl;
if (x == 1)
{
for (int i = 0; i < _arrSize; i++)
_sum += a[i];
cout << "The Sum of the elements is: " << _sum;
}
if (x == 2)
{
for (int i = 0; i < _arrSize; i++)
{
for (int j = i+1; j < _arrSize; j++)
{
if (a[i] < a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
cout << "The number from largest to smallest: \n";
for (int i = 0; i < _arrSize; i++)
{
cout << " ";
cout << a[i];
cout << "\n";
}
}
if (x == 3)
{
for (int i = 0; i < _arrSize; i++)
{
for (int j = i+1; j < _arrSize; j++)
{
if (a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
cout << "The number from smallest to largest: \n";
for (int i = 0; i < _arrSize; i++)
{
cout << " ";
cout << a[i];
cout << "\n";
}
}
if (x == 4)
{
for (int i = 0; i < _arrSize; i++)
_sum += a[i];
Ave = _sum/_arrSize;
cout << "Average of the elements: " << Ave;
}
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)