Assign negativecntr with the number of negative values in the linked list.

In C++ please. Assign negativeCntr with the number of negative values in the linked list. 1 #includeくiostream» 2 #include <cstd11b 3 using n22Insert node after this node. 23 Before: this - next 24 After: this - - node next 25/ 26 void IntNode: :InsertAfter(IntNode41 42 43 int main() f 44 IntNode* headobj nullptr; // Create intNode objects 45 IntNode currObj nullptr; 46 IntNode* 1astobj=62 while (currObj - nullptr) 63 currObj-currObj->GetNext); 64 65 66 out <<endl; 67 68 currObj- headobj; 69 while (currObj !=

Answer

If you have any doubts, please give me comment… currObj = headObj; // Count number of negative numbers while(currObj != nullptr){

if(currObj->GetDataVal()<0)

negativeCnt++;

currObj = currObj->GetNext();

}

cout<<“Number of negatives: “<<negativeCnt<<endl;

Leave a Comment