troubleshooting Question

i made my first linklist but i dont know how to pass values in it to sumSquares, pls help!!!!!

Avatar of jxharding
jxharding asked on
C++
7 Comments2 Solutions317 ViewsLast Modified:

#include <iostream>
using namespace std;

struct nodeType
{
 int info;
 nodeType *link;
};


nodeType* buildListForward()
{
  nodeType *first, *last,*newNode;
  int num;
  cout<<"Enter A list of integers ending with -999.\n";
  first = NULL;
 
  while (num != -999)
  {
  newNode = new nodeType;
  assert(newNode != NULL);
  newNode->info = num;
  newNode->link = NULL;

  if (first == NULL)
  {
        first = newNode;
        last = newNode;
  }
  else
  {
      last->link = newNode;
      last = newNode;
  }
  cin>> num;
 
  }//end while
 
  return first;
}//end buildlistforward

//int sumSquares1(nodeType<int> * list)
//{
//    if (list != NULL)
//        return (list->info*list->info) + sumSquares1(list->link);
//}



int main() {

 
 buildListForward();
  // how can i implement this buildlistforward so i can use sumSquares1?
  // pls show me as much as you can!
 

  return 0;
}


ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros