Running while loop

Aug 22, 2016 at 8:32am
Why cant I get this to display anything when running in codeblocks?

#include <iostream>
using namespace std;
1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
int s = 0;
int n = 0;

while (n <= 5);
{
    cout << n << s;

    s =+ n;//s = s + n
    n++; // n = n + 1
}
Last edited on Aug 22, 2016 at 8:40am
Aug 22, 2016 at 8:36am
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;

int main()
{
    int s = 0;
    int n = 0;
    
    while (n <= 5) // <--
    {
        cout << n << s;
        
        s += n;//s = s + n <---
        n++; // n = n + 1
    }
    return 0;
}


0010213346510Program ended with exit code: 0
Last edited on Aug 22, 2016 at 8:37am
Aug 22, 2016 at 8:55am
Yes I agree...but why ?
Aug 22, 2016 at 9:10am
closed account (z05DSL3A)
Can you see the changes kermort made to your code?
Aug 23, 2016 at 7:07am
yeah ...I see it now ...that's a silly mistake thank you
Topic archived. No new replies allowed.