Press "Enter" to skip to content

C – Loops 2

In previous essay , I used if – else and while loops when make a program. In this essay , I will use do-while and for loops. Do – while loop is different type of while loops. You can see the previous essay in here.

Firstly , I will make a program , using with the do – while loop . In this program, Program will take a number from the user with a condition. Condition is number must be smaller than 50 (I will use if-else for condition) . Then program will add 5 to number until the number equal to 50.

The differences between the while and do-while is, In do-while first run and control the situation but in while first control the situation then run the code.

Screen Outpu;

Now, I will make program , using with the for loop. Program will take 2 numbers from the user and compare with each other , then program will add 1 to the small number and when they are equal , program will be finish.

In for loops , program look the condition in for , if the condition right , program will run.

Screen Output;

I will make fibonacci loop , using with the for loop. fibonacci loop is ,collecting the number from the previous one. Code syntax is ;

Screen Output ;




Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *