Please fix the following C++ code to compile correctly in Visual Studio
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void menu_driven()
{
cout << "Press 1 to display the agesn";
cout << "Press 2 to change the age of Billionairen";
cout << "Press 3 to display the minimum age of all Billionairesn";
cout << "Press 4 to display the average ages of all Billionairesn";
cout << "Press 5 to display the ages sorted in ascending ordern";
cout << "Press 6 to Quitn";
}
void result(int choice)
{
int NUM_BILLIONAIRES = 2600;
int position;
int change_age;
int ages[NUM_BILLIONAIRES] =
{
50,58,73,66,91,49,48,77,66,64,59,80,82,68,37,73,
67,72,77,44,86,59,86,57,38,64,84,82,53,51,52,85,
84,50,64,57,93,75,94,64,82,86,73,71,68,68,76,83,
79,76,77,86,53,73,50,59,80,51,56,30,76,58,51,81,
89,40,79,57,82,66,72,60,83,64,60,91,55,59,55,77,
67,66,56,86,71,40,65,55,71,60,68,72,54,71,74,65,
61,76,63,66,75,81,64,54,82,54,86,64,35,58,69,89,
55,59,66,58,82,71,42,58,67,54,37,42,92,49,44,92,
63,64,66,64,64,58,70,49,82,57,73,56,67,81,54,89,
50,56,70,64,92,63,66,93,84,94,59,77,63,77,72,72,
57,56,98,52,74,93,40,73,37,68,62,61,42,69,54,69,
59,50,43,82,71,54,75,74,79,80,40,71,48,66,74,46,
65,80,56,72,70,40,79,56,69,79,52,89,66,46,77,76,
67,62,69,57,64,31,33,93,54,66,76,53,38,74,65,56,
53,70,73,54,75,64,75,54,78,71,63,88,83,55,90,76,
59,69,57,92,76,64,64,64,91,56,56,60,74,68,65,57,
57,58,71,58,64,72,70,80,59,72,54,41,84,74,46,43,
81,38,57,36,40,74,71,70,57,57,61,64,78,49,84,55,
57,61,63,65,78,49,73,87,64,51,74,60,65,71,65,64,
79,58,53,78,71,64,61,64,46,71,53,70,63,58,77,71,
81,69,51,68,80,67,60,67,69,78,80,93,74,67,93,85,
79,64,68,66,37,52,53,78,53,71,83,80,64,55,72,86,
71,55,67,82,64,89,77,61,80,87,88,68,52,48,91,67,
61,90,79,84,62,59,39,58,58,39,52,60,73,79,73,55,
60,51,65,78,54,62,55,36,52,34,61,60,40,75,52,76,
67,60,51,76,57,60,69,57,33,58,58,57,77,53,59,84,
95,72,45,58,77,31,55,57,67,59,70,74,60,64,61,80,
58,72,67,92,28,53,57,61,86,57,53,71,64,65,69,57,
58,70,58,50,73,82,70,50,84,70,80,76,74,75,88,84,
65,70,60,54,70,59,64,77,83,50,58,70,80,76,58,63,
84,78,64,49,60,65,62,64,80,45,87,46,66,78,95,80,
71,46,79,85,53,58,77,63,57,38,71,66,54,71,80,81,
87,90,44,76,77,56,48,59,65,51,64,61,92,67,60,54,
53,80,77,62,79,64,52,74,55,81,67,91,89,58,54,57,
79,76,78,69,64,73,55,64,73,71,72,47,48,66,75,63,
60,61,50,78,68,41,71,44,83,54,72,64,87,57,49,50,
58,55,64,42,81,76,63,54,65,54,62,59,59,66,64,53,
82,89,59,85,57,41,59,64,87,70,71,80,65,62,69,63,
82,68,90,54,51,55,66,79,71,56,77,63,61,49,67,69,
66,77,80,56,97,68,73,66,60,64,67,59,57,78,60,48,
79,55,60,96,59,70,80,68,62,28,56,58,64,67,82,80,
57,58,89,56,70,35,75,52,67,50,49,88,63,62,69,57,
70,65,93,49,81,80,64,61,81,77,61,40,61,77,55,64,
78,84,75,95,76,67,55,64,81,86,70,60,85,66,39,62,
81,63,66,74,54,63,56,67,94,51,82,63,52,57,89,91,
64,67,67,72,76,51,53,68,54,76,68,87,66,44,78,71,
92,40,81,80,42,58,53,88,78,61,69,66,72,59,72,72,
68,42,57,74,64,66,82,40,40,71,56,82,79,64,40,66,
59,67,64,54,8.
Please fix the following C++ code to compile correctly in Vi.pdf
1. Please fix the following C++ code to compile correctly in Visual Studio
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void menu_driven()
{
cout << "Press 1 to display the agesn";
cout << "Press 2 to change the age of Billionairen";
cout << "Press 3 to display the minimum age of all Billionairesn";
cout << "Press 4 to display the average ages of all Billionairesn";
cout << "Press 5 to display the ages sorted in ascending ordern";
cout << "Press 6 to Quitn";
}
void result(int choice)
{
int NUM_BILLIONAIRES = 2600;
int position;
int change_age;
int ages[NUM_BILLIONAIRES] =
{
50,58,73,66,91,49,48,77,66,64,59,80,82,68,37,73,
67,72,77,44,86,59,86,57,38,64,84,82,53,51,52,85,
84,50,64,57,93,75,94,64,82,86,73,71,68,68,76,83,
79,76,77,86,53,73,50,59,80,51,56,30,76,58,51,81,
89,40,79,57,82,66,72,60,83,64,60,91,55,59,55,77,
67,66,56,86,71,40,65,55,71,60,68,72,54,71,74,65,
61,76,63,66,75,81,64,54,82,54,86,64,35,58,69,89,
55,59,66,58,82,71,42,58,67,54,37,42,92,49,44,92,
63,64,66,64,64,58,70,49,82,57,73,56,67,81,54,89,
50,56,70,64,92,63,66,93,84,94,59,77,63,77,72,72,
57,56,98,52,74,93,40,73,37,68,62,61,42,69,54,69,
59,50,43,82,71,54,75,74,79,80,40,71,48,66,74,46,
65,80,56,72,70,40,79,56,69,79,52,89,66,46,77,76,
67,62,69,57,64,31,33,93,54,66,76,53,38,74,65,56,
53,70,73,54,75,64,75,54,78,71,63,88,83,55,90,76,
59,69,57,92,76,64,64,64,91,56,56,60,74,68,65,57,
57,58,71,58,64,72,70,80,59,72,54,41,84,74,46,43,
81,38,57,36,40,74,71,70,57,57,61,64,78,49,84,55,
57,61,63,65,78,49,73,87,64,51,74,60,65,71,65,64,
79,58,53,78,71,64,61,64,46,71,53,70,63,58,77,71,
6. {
cout << "nDisplaying the minimum age of all Billionaires:";
if (len > 0)
{
int smallest = ages[0]; //assume that first element is smallest
for (int i = 1; i < len; i++)
{
if (smallest > ages[i])
{
smallest = ages[i]; //update smallest
}
}
cout << "Smallest : " << smallest << endl;
}
else
{
cout << "No elements in the array." << endl;
}
break;
}
case 4:
{
cout << "nDisplaying the average age of all Billionaires:";
int sum = 0;
// Find sum of all array elements
for (int i = 0; i < len; i++)
{
sum += ages[i];
}
float average = (float)sum / len;
cout << "nAverage = " << average;
break;
}
case 5:
{
cout << "nDisplaying the sorted array:";
sort(ages, ages + len, greater<int>());
// Print the sorted array
cout << "nDescending Sorted Array:";
for (int i = 0; i < len; i++)
cout << ages[i] << " ";
break;
7. }
case 6:
{
cout << "nExiting the menu";
exit(0);
}
}
}
int main()
{
int choice;
// Display the menu
menu_driven();
// Enter the choice
cout << "Enter your choice:n";
cin >> choice;
cout << "Choice is " << choice << endl;
// Display the result
// according to the choice
result(choice);
return 0;
}