This is my C++ Codes but it has errors when I run it. The error states that at line 16, the expression must have a constant value. Can you fix the errors? Please still use header files iostream. //Start of program #include using namespace std; int main() { //Initialize variable int size; //Prompt the user to enter the size of the array N cout << "Enter the size of the array N: "<> size; //Declare array and initialize variables int N[size], i, j, temp; int count = 1; //Prompt the user to enter the integer value for the array N cout << "Enter the " << size << " elements for the array N: "; //Use for loop to iterate the value of i for (i = 0; i < size; i++) { cin >> N[i]; //Store each integer } //Nested loop for (i = 0; i < size; i++) //Outer for loop { for (j = i + 1; j < size; j++) //Inner for loop { if (N[i] > N[j]) //If the element at i is greater than the element at j { temp = N[i]; //Swap elements N[i] = N[j]; N[j] = temp; } } } //Display the heading cout << "\n\t\tN \t count"; cout << "\n\t ---------------"; //Count the number of occurrences //Nested loop for (i = 0; i < size; i++) //Outer for loop { for (j = 0; j < i; j++) //Inner for loop { //If the elements at i and j are same, count if (N[i] == N[j]) count++; } //If the values of the i and j are the same if (i == j) { //If the next element is not same as the current element if (N[i] != N[i + 1]) cout << "\n\t\t" << N[i] << "\t\t" << count; //Display the element and total number of occurrence of the element } } cout << endl; //End of program return 0; }
This is my C++ Codes but it has errors when I run it. The error states that at line 16, the expression must have a constant value. Can you fix the errors? Please still use header files iostream.
//Start of program
#include <iostream>
using namespace std;
int main()
{
//Initialize variable
int size;
//Prompt the user to enter the size of the array N
cout << "Enter the size of the array N: "<<endl;
cin >> size;
//Declare array and initialize variables
int N[size], i, j, temp;
int count = 1;
//Prompt the user to enter the integer value for the array N
cout << "Enter the " << size << " elements for the array N: ";
//Use for loop to iterate the value of i
for (i = 0; i < size; i++)
{
cin >> N[i]; //Store each integer
}
//Nested loop
for (i = 0; i < size; i++) //Outer for loop
{
for (j = i + 1; j < size; j++) //Inner for loop
{
if (N[i] > N[j]) //If the element at i is greater than the element at j
{
temp = N[i]; //Swap elements
N[i] = N[j];
N[j] = temp;
}
}
}
//Display the heading
cout << "\n\t\tN \t count";
cout << "\n\t ---------------";
//Count the number of occurrences
//Nested loop
for (i = 0; i < size; i++) //Outer for loop
{
for (j = 0; j < i; j++) //Inner for loop
{
//If the elements at i and j are same, count
if (N[i] == N[j])
count++;
}
//If the values of the i and j are the same
if (i == j)
{
//If the next element is not same as the current element
if (N[i] != N[i + 1])
cout << "\n\t\t" << N[i] << "\t\t" << count; //Display the element and total number of occurrence of the element
}
}
cout << endl;
//End of program
return 0;
}
![](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbde9f1e4-b08a-483c-804f-c5d663c770e0%2F493cfa71-ce7a-4f4c-a9a7-9d6ccdf98334%2F5xz3ov.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)