In picture one - Line 12 - int main(), there is a green squiggly line under the word main   picture 2 -  My output is not generated. I showed how when you input the number of elements for arrays and click enter the numbers do not appear, then I clicked enter more times for you to see nothing happened whrn I clicked enter until I input numbers myself. Thank you I hope this is what you were asking for. I us Visual Studio 2019, C++ console for Windows 10.   If possible, please help me. heck_circle Expert Answer thumb_up   thumb_down Step 1 Required: Below this question was asked and answered with the output to prove it works from an expert, but for some reason when I put the code into my MS Visual Studio 2019, C++ console for Windows 10 there appeared to be a warning at line 6  -  int main(){.  I received a warning under the word main (green squiggly line) and my output don't work for me as yours did for you. Do you think you can help me please. Step 2 Dear student below is screenshot from the code, in VS Code. it is running fine and showing no Error. from your question, since you have not posted the exact error. it will be difficult to troubleshoot. please post your exact error code screenshot. Code: #include #include #include using namespace std; vector mode(int[], int); int main() { int n, a[100000]; vector answer; vector::iterator it; cout << "Enter number of elements in array:" << endl; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } answer = mode(a, n); if (answer.size() == 0) { cout << "There are no modes" << endl; } else if (answer.size() == 1) { cout << "Mode is:" << endl; } else { cout << "Modes are:" << endl; } for (it = answer.begin(); it != answer.end(); it++) { cout << *it << " "; } } vector mode(int a[], int n) { int greater = 0; vector v; map m1, m2; for (int i = 0; i < n; i++) { m1[a[i]]++; if (m1[a[i]] > greater) greater = m1[a[i]]; } for (int i = 0; i < n; i++) { if (m1[a[i]] == greater && greater > 1 && m2[a[i]] != 1) { v.push_back(a[i]); m2[a[i]] = 1; } } return v; }   Output:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
 
In picture one - Line 12 - int main(), there is a green squiggly line under the word main
 
picture 2 -  My output is not generated. I showed how when you input the number of elements for arrays and click enter the numbers do not appear, then I clicked enter more times for you to see nothing happened whrn I clicked enter until I input numbers myself. Thank you I hope this is what you were asking for. I us Visual Studio 2019, C++ console for Windows 10.
 
If possible, please help me.
heck_circle

Expert Answer

thumb_up
 
thumb_down
Step 1

Required:

Below this question was asked and answered with the output to prove it works from an expert, but for some reason when I put the code into my MS Visual Studio 2019, C++ console for Windows 10 there appeared to be a warning at line 6  -  int main(){.  I received a warning under the word main (green squiggly line) and my output don't work for me as yours did for you.

Do you think you can help me please.

Step 2

Dear student below is screenshot from the code, in VS Code. it is running fine and showing no Error. from your question, since you have not posted the exact error. it will be difficult to troubleshoot. please post your exact error code screenshot.

Code:

#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<int> mode(int[], int);
int main()
{
int n, a[100000];
vector<int> answer;
vector<int>::iterator it;
cout << "Enter number of elements in array:" << endl;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
answer = mode(a, n);
if (answer.size() == 0)
{
cout << "There are no modes" << endl;
}
else if (answer.size() == 1)
{
cout << "Mode is:" << endl;
}
else
{
cout << "Modes are:" << endl;
}
for (it = answer.begin(); it != answer.end(); it++)
{
cout << *it << " ";
}
}
vector<int> mode(int a[], int n)
{
int greater = 0;
vector<int> v;
map<int, int> m1, m2;
for (int i = 0; i < n; i++)
{
m1[a[i]]++;
if (m1[a[i]] > greater)
greater = m1[a[i]];
}
for (int i = 0; i < n; i++)
{
if (m1[a[i]] == greater && greater > 1 && m2[a[i]] != 1)
{
v.push_back(a[i]);
m2[a[i]] = 1;
}
}
return v;
}
 
Output:
 
 
 
Micresoft Vioual Studio Debug Censele
Enter number of elements in array:
There are no modes
C:Users\deedm\C++source codelConsolelpplication7\Debug\Consolelpplication7.exe (process 10344) exited with code e.
To automatically close the console when debugging stops, enable Tools-Options-Debugging-Automatically close the console when debugging stops.
Press any key to close this window
117 AM
P Type here to search
O 66F A O
Transcribed Image Text:Micresoft Vioual Studio Debug Censele Enter number of elements in array: There are no modes C:Users\deedm\C++source codelConsolelpplication7\Debug\Consolelpplication7.exe (process 10344) exited with code e. To automatically close the console when debugging stops, enable Tools-Options-Debugging-Automatically close the console when debugging stops. Press any key to close this window 117 AM P Type here to search O 66F A O
pd File
View Project Buld Debu Tet
Tools Eatensions Window Help Search (Cot
Conolehplication?
Edit
Analyon
O.O 3- ?
- Local Windows Debugger- : ?:
Debug
e Live Share
ConsoleApplicationtapp+ X
NConseleApplication
- IGebal Scepe
-o modeint int
I Consolekpplication7.cpp : This file contains the "nain function. Progran execution begins and ends there.
nclude lestrea
include evector
nclude cap
using nanespace std,
vectoreint mode(int(), int)
10
t lot)
12
13
14
15
16
int n, a(1000);
17
18
vectorcint anser
19
20
vectorcintsiterator it;
21
cout e "Enter number of elenents in array:" e endl;
for (int i- e; ie n; 1++)
cin a[i]i
31
anser ode(e,
35
s00
Ln 110 Ch2 TAS
CRUF
Emor List - Cument Project (Consoleapplication)
1:16 AM
P Type here to search
O 66F
/24/2021
Team Explorer
Transcribed Image Text:pd File View Project Buld Debu Tet Tools Eatensions Window Help Search (Cot Conolehplication? Edit Analyon O.O 3- ? - Local Windows Debugger- : ?: Debug e Live Share ConsoleApplicationtapp+ X NConseleApplication - IGebal Scepe -o modeint int I Consolekpplication7.cpp : This file contains the "nain function. Progran execution begins and ends there. nclude lestrea include evector nclude cap using nanespace std, vectoreint mode(int(), int) 10 t lot) 12 13 14 15 16 int n, a(1000); 17 18 vectorcint anser 19 20 vectorcintsiterator it; 21 cout e "Enter number of elenents in array:" e endl; for (int i- e; ie n; 1++) cin a[i]i 31 anser ode(e, 35 s00 Ln 110 Ch2 TAS CRUF Emor List - Cument Project (Consoleapplication) 1:16 AM P Type here to search O 66F /24/2021 Team Explorer
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education