Running while loop

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
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
Yes I agree...but why ?
closed account (z05DSL3A)
Can you see the changes kermort made to your code?
yeah ...I see it now ...that's a silly mistake thank you
Topic archived. No new replies allowed.