Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this C++ code #include #include #include using namespace std; double median(std::vector vec){ int size = vec.size(); if(size > 0 ){ std::sort(vec.begin(),vec.end()); int middle

I have this C++ code

#include #include

#include using namespace std;

double median(std::vector vec){ int size = vec.size(); if(size > 0 ){ std::sort(vec.begin(),vec.end());

int middle = size / 2; double median = 0.0; if(size % 2 == 0){ median = (vec[middle] + vec[middle+1]) / (double)2; }else{ median = vec[middle]; } return median; } return 0.0; }

int main(){ bool keep_on=true; while(keep_on){ vector v; double in_val = 0; cout<<"Please insert numeric values to find the median:(non-numeric value to terminate input)"; while(cin >> in_val){ v.push_back(in_val); } cin.clear(); cin.ignore(1,' ');

cout<<"Median: "<

int again = 0; while(true){ cout<<"1: Go again?"<>again; if(again == 1) break; else if(again == 2){ keep_on = false; break; } else{ cout<<"Input only 1 or 2 please"<

this code runs perfectly on other compilers but I am required to use Gnome Terminal 2.7.3 and it shows me this error

CPP test test.cpp*** test.cpp:7: instantiated from here test.cpp:7: instantiated from here test.cpp:7: instantiated from here test.cpp:11: instantiated from here test.cpp:8: instantiated from here Can you tell me what this error means? and how to fix it so the code runs on the gnome terminal?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

=+ What are their likely goals for settlement?

Answered: 1 week ago