THE QUESTION
with a positive integer s read from the keyboard, find all sequences of two or more consecutive integers whose sum is = to s.... for example.... if user enters 15
result should show
1 2 3 4 5....
4 5 6...
7 8....
MY TRY
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
int num, total = 0;
cout << "Enter a digit to work it out: " ;
cin >> num;
cout << endl;
for (int n = 1; n <= num; n++)
{
for (int i = n; i <= num; i++)
{
if (i <= (num / 2)+ 1)
{
total+= n;
cout << i << " ";
}
}
cout << endl;
}
cout << endl << endl;
system("PAUSE");
return 0;
}
MY OUTPUT
if i enter 15 is
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8
3 4 5 6 7 8
4 5 6 7 8
5 6 7 8
6 7 8
7 8
8
PLZ HELP...i dnt know what to do next...im new to this.... :/