Question: #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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!