[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
Solved

Posted on 1998-02-11
Medium Priority
175 Views
I have a linked list and need to total it up. How would I go
about doing it ??  The best I came up with is:

struct List
{ int data;
node * next;
}
typedef node* next;

total = data;

total =+ data;

cur = cur* next;

Thanks for the help.
0
Question by:chasa
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 1

Accepted Solution

yl earned 450 total points
ID: 1181814
struct List
{
int data;
node * next;
};

{
int total = 0;

while (cur != NULL) {
total += cur->data;
cur = cur->next;
}

return (total);
}

0

LVL 3

Expert Comment

ID: 1181815
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
###### Suggested Courses
Course of the Month12 days, 22 hours left to enroll