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
#include
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[]) {
list
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).

VulpesPosted Mar 6, 2015, 6:33 PM
VulpesPosted Mar 7, 2015, 8:24 AM
1. I've added a new variable, N, to hold the number which the numbers in the linked list are to be multiplied by.
2. I've then asked the user for the value of N.
3. Finally, the first number in the linked list has been multiplied by N and the result stored in the existing variable num:
num = N * lalista.front();
The rest of the code then works as it did before except that it displays and adds the numbers after multiplication by N rather than just the numbers themselves.
Carlos Robles CalderonPosted Mar 6, 2015, 7:21 PM