I am trying to count count from 1-10 and print out each number. This is the code I am running

``````int c = 1;
void setup() {
// put your setup code here, to run once:

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if ( c<= 10) {
Serial.println("c is less than 10");
Serial.println(c);
c + 1;
}
else {
Serial.println("C equals 10");
Serial.println(c);
}
}
``````

When I run the code this happens:

``````ss than 10
1
c is less than 10
1
c is less than 10
1
c is less than 10
1
c is less than 10
1
c is les
``````

I think it happens because the loop resets the if statement every time. Is it possible to make the loop not end so it runs c from 1 to 10?

``````c + 1;
``````

what is that supposed to do?

`````` c + 1;
``````

That line is useless. Did you mean to assign the result back to c?

``````c = c+ 1;
``````

Or the shorthand

``````c+=1;
``````

Or

``````c++;
``````

I thought it would add one to c doing c +1;
I tried

``````c++;
``````

and `c = c+1; `

But that still returns the same integer over and over again.
I also tried this:

``````void setup() {
// put your setup code here, to run once:

Serial.begin(9600);
}

void loop() {
int c = 2;
int b = 5;

// put your main code here, to run repeatedly:
if ( c<= 10) {
Serial.println("c is less than 10");
Serial.println(c);
c = c+1;
b = c + b;
Serial.println(b);
}
else {
Serial.println("C equals 10");
Serial.println(c);
}
delay(1500);
}
``````

B ends up being 8, so C has been added one. However, when I run the code it prints out

``````c is less than 10
2
8
c is less than 10
2
8
c is less than 10
2
8
``````

So I think the loop resets each time. Is it possible to not reset the loop so the value for C is saved and it eventually adds up to 10?

``````void loop() {
int c = 2;
int b = 5;
``````

because c and b are created each time loop() runs and are destroyed each time loop() ends.

``````void loop() {