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...







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:"=""><>

cin >> n;

for (int i = 0; i < n;="">

{

cin >> a[i];

}

answer = mode(a, n);

if (answer.size() == 0)

{

cout < "there="" are="" no="" modes"=""><>

}

else if (answer.size() == 1)

{

cout < "mode="" is:"=""><>

}

else

{

cout < "modes="" are:"=""><>

}

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;="">

{

m1[a[i]]++;

if (m1[a[i]] > greater)

greater = m1[a[i]];

}

for (int i = 0; i < n;="">

{

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<br>Enter number of elements in array:<br>There are no modes<br>C:Users\deedm\C++source codelConsolelpplication7\Debug\Consolelpplication7.exe (process 10344) exited with code e.<br>To automatically close the console when debugging stops, enable Tools-Options-Debugging-Automatically close the console when debugging stops.<br>Press any key to close this window<br>117 AM<br>P Type here to search<br>O 66F A O<br>

Extracted 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<br>View Project Buld Debu Tet<br>Tools Eatensions Window Help Search (Cot<br>Conolehplication?<br>Edit<br>Analyon<br>O.O 3- ?<br>- Local Windows Debugger- : ?:<br>Debug<br>e Live Share<br>ConsoleApplicationtapp+ X<br>NConseleApplication<br>- IGebal Scepe<br>-o modeint int<br>I Consolekpplication7.cpp : This file contains the

Extracted 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
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here