sum up 2 inputs,the sum is added to the next num of the 2nd input and so on

hello..its my first time here..

i need help regarding an assignment..any help with do pls..i understand the flow but don't quite know how to start..
the first two numbers (a & b) are inputs and to start the sequence of the adding..it will then display the final answers..

the flow is:
a+b=c
(b+1)+c=d
(c+1)+d=e
(d+1)+e=f
.
.
.
so on..

c+d+e+f+....=total

until the max number inputted for the adding is reached..


..thank you..


Welcome to cplusplus.com! We dont do homework for people, as with many other forums

You should start by reading a good tutorial:
http://cplusplus.com/doc/tutorial/introduction/

What youll want to know about is basic input and output:
http://cplusplus.com/doc/tutorial/basic_io/
And youll want to know about variables:
http://cplusplus.com/doc/tutorial/variables/

If youve made some code yourself, post it here, and we will (probably)always help you
Last edited on
uhm...here it is...i know basic inputs and outputs...its the loops im confused about..
it just displays the inputted number and cant total..i dont know either how to increment..

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
#include<iostream.h>
#include<conio.h>
//using namespace std;


void main()
{
int iNumberInputs;
int sum=0;

cout << "NuberInputs" << endl;
cin >> iNumberInputs;
int* iInputs = new int

[iNumberInputs];
for (int x = 0; x<iNumberInputs; x++){
cout << "Inputs: "<< endl;
cin >> iInputs[x];
{

for (int y = 0; y<iNumberInputs; y++){
sum = sum+iInputs[y];

cout << sum;
cout<<endl;
}

getch();
}
change
1
2
3
int* iInputs = new int

[iNumberInputs];

to int* iInputs = new int[iNumberInputs];
just for readability,

the problem is that youre doing a { bracket at line 19, you should be closing the for loop there, so make it a } bracket instead, if you fix that itll probably compile, and work

lastly, main should return int.
Topic archived. No new replies allowed.