Sum with while

Hello,
I want similar this out put without any used array. just used while and do while.

Please Enter Number : 1
Please Enter Number : 2
Please Enter Number : 3
Please Enter Number : 4
Please Enter Number : 5
1 + 2 + 3 + 4 + 5 = 15

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
 #include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i,x,s=0;
i = 0;


do
{
cout << "Please Enter Number >" << '\t';
cin >> x;
s = s + x;
i++;

} while (i != 5);


cout << "sum = " << s << '\t' <<'\n';





return 0;
}
Just declare five variables and do it the same way as with an array.
Topic archived. No new replies allowed.