include::../description.adoc[]

== Noncompliant Code Example

----
for (int i = 0; i < 10; i++) {
  ...
  i = i - 1; // Noncompliant
  ...
}

for (int i = 0; i < getMaximumNumber(); i++) {  // Noncompliant
}
----

== Compliant Solution

----
for (int i = 0; i < 10; i++) {
  ...
}
int stopCondition = getMaximumNumber();
for (int i = 0; i < stopCondition; i++) {
}
----

== See

* MISRA C:2004, 13.6 - Numeric variables being used within a _for_ loop for iteration counting shall not be modified in the body of the loop.
* MISRA {cpp}:2008, 6-5-3 - The _loop-counter_ shall not be modified within _condition_ or _statement_.

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
