Can You Tell Me What Is It For?

Ok, so I build this


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int sumSequensce(void)
{
    int accumulator=0;
    for(;;)
    {
        int value = 0;
        cout << "Enter next number: " << endl;
        cin >> value;

        if(value<0)
        {
            break;
        }

        accumulator = accumulator + value;
    }

    return accumulator;
}

int main(int nNumberofArgs,char* pszArgs[])
{
    cout << "This program sums multiple series\n"
         << "of numbers. Terminate each sequence\n"
         << "by entering a negative number.\n"
         << "Terminate the serie by entering two\n"
         << "negative numbers in a row.\n"
         << endl;

         int accumulatedValue;
         for(;;)
         {
             cout << "Enter next sequence: " << endl;
             accumulatedValue = sumSequensce();

             if (accumulatedValue==0)
             {
                 break;
             }

             cout << "The total is " << accumulatedValue << "\n" << endl;
         }

         cout << "Thank you" << endl;

         system ("PAUSE");
         return 0;
}


but when I compile it, it looks like this
This program sums multiple series
of numbers. Terminate each sequence
by entering a negative number.
Terminate the serie by entering two
negative numbers in a row.

Enter next sequence:
Enter next number:


The input for "next sequence" is skiped, so this is my fault, or this


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int sumSequensce(void)
{
    int accumulator=0;
    for(;;)
    {
        int value = 0;
        cout << "Enter next number: " << endl;
        cin >> value;

        if(value<0)
        {
            break;
        }

        accumulator = accumulator + value;
    }

    return accumulator;
}


is useless?


Thanks
your code

1
2
3
4
5
6
7
cout << "Enter next sequence: " << endl;
             accumulatedValue = sumSequensce();

             if (accumulatedValue==0)
             {
                 break;
             }


You need to add a

cin >> "Variable"

to get it into the seqencse function
Topic archived. No new replies allowed.