How to multiply N number for each number in a Linked list?

Mar 6 2015 5:37 PM
Well, i'm a total noob in this of codding and programming so sorry if i say something stupid or without logic at all... Wel the problem is that i have a algorithm or a program that i have to do (University Homework), and i dont get how to do it.. This is what i have: 
 
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <list>

using namespace std;

int main(int argc, char *argv[]) {
list<double> lalista;
double num, suma=0;

cout << "A Simple calc:" << endl;

do {
cout << "Insert a numbrer, or  0 to exit: ";
cin >> num;
if (num !=0) lalista.push_back(num);
}
while (num !=0);

cout << "-----------" << endl;

while( !lalista.empty() )
{
num = lalista.front();
cout << setw(10) << num << endl;
suma += num;
lalista.pop_front();
}
cout << "----------" << endl;

cout << setw(10) << suma << endl;

system ("PAUSE");

return EXIT_SUCCESS;
}
 
in this one is adding the whole thing, and i dont get how to put it to multiply each of the number stored in the linked list, could help me? Thanks (i'm working in c++ sorry, if i disrupt you).

Answers (3)