Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; struct node { int data; node *next; }; class IntegerLinkedList { private: node *head; public: IntegerLinkedList() { head = NULL; }

#include using namespace std; struct node { int data; node *next; }; class IntegerLinkedList { private: node *head; public: IntegerLinkedList() { head = NULL; } void addFront(int value) { node *temp = new node; temp->data = value; temp->next = NULL; if (head == NULL) { head = temp; temp = NULL; } else { temp->next = head; head = temp; } } int countPositive() { int count = 0; node *trav = head; while (trav != NULL) { if (trav->data>0) count++; trav = trav->next; } return count; } }; #include  #include  //#include "IntegerLinkedList.h" using namespace std; int main() { IntegerLinkedList mylist; cout << "Enter number of integers : "; int n, value; cin >> n; cout << "Enter " << n << " integers" << endl; for (int i = 0; i < n; i++) { cin >> value; mylist.addFront(value); } cout << "countPositive: " << mylist.countPositive() << endl; system("pause"); // comment/uncomment if needed }

Hello, could you please add a function to fine the smallestPositive # like example .... -3 5 -6 8 7 the smallest positive is 5.

Thank you

Best

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago