Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Loop syntax C language

I’m looking to print in every line The value of (f) from 10 to 0.
I only get it to (2) using thin syntax of Loop
I can’t understand how this loop works, any hand it will be a great help to me I will be thankful.
I’m using C programming language

int f = 10;
for(f--; f++; f-=2)
printf("%d\n", f);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A loop of the form

for (setup; condition; repeat) body

is roughly equivalent to:

setup;
while (condition) {
    body;
    repeat;
}

So substitute the parts of your loop into this template and you should be able to see how it works.

int f = 10;
f--;
while (f++) {
    f -= 2;
    printf("%d\n", f);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading