Lab 1 In class we discussed some basic ideas about how to convert (map) an Algor
ID: 3732566 • Letter: L
Question
Lab 1 In class we discussed some basic ideas about how to convert (map) an Algorithm into C++, develop your skills by converting the following algorithm based on an answer (see below) to question 6 from section 3.1 in the textbook. Your solution should be a C++ main.cpp file that looks like this: // Your name: // Lab Number || Date: // Description: #include #include // your descriptive comments int negatives(vector d) { // your work goes here int main() { vector data = {-1, 5, 5, -4, 5, 6, 33, -2, 44 }; // arbitrary numbers int n = negatives(data); std::coutExplanation / Answer
int negatives(vector<int> d) {
int count = 0;
for(int i = 0; i < d.size(); ++i) {
if(d[i] < 0) {
count++;
}
}
return count;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.