print 0 1 2 3 4 in c while loop 1

print 0 1 2 3 4 in c while loop

int k=0;

while (k <= 5)
{
    printf("%d", k);
    k = k + 1;
}

Here is what the above code is Doing:
1. We create a variable k and set it to 0.
2. We create a while loop that will run as long as k is less than or equal to 5.
3. Inside the while loop, we print the value of k.
4. We increment k by 1.
5. We go back to step 2.

The output of the above code is:
012345

Similar Posts