While and Do While Loop Comparison – Control Statements – C Programming Language – First Year Engg

While and Do While Loop Comparison – Control Statements – C Programming Language – First Year Engg


Hello Students one of the most important theory question which is an ass regularly in the exams is the comparison of the two loops called as while & Do While what exactly are the differences between while and do-while loop now you can quote these differences with examples or with illustrations awesome I’ll spell of some statements slowly listen to them carefully noted on a piece of paper so that you’ll be able to reproduce it for any number of times as your reservation so first comparison is based on the players of the condition where the condition is tested now you know why loop the condition as if you if you if you are able to recollect the exact syntax which is stated for a while as well as do i it says the condition is tested at the beginning of the loop so the condition the condition is tested at the beginning of the loop beginning of the loop and in a do-while loop so no do I look the condition is tested at the end of the loop so where the condition is tested that is the first difference now the second difference is since the condition is tested after the beginning and we decide whether to continue or to stop after the entry point itself we call this while as a entry controlled loop whereas in a dual loop the condition is tested at the end of the loop if you remember the condition is tested at the end of the loop hence we call this as exists a controlled loop as the control of the loop whether to restart it or whether to stop he is not made at the beginning but at the end hence because this as exists to control you now probably the differences which I have quoted are very very minor in nature but this is the one which is major difference now always remember that in exams not to forget this particular difference most of the examiners will say that this is the actual and the core difference between while and do-while loop now what is this difference when the condition is false for the first time suppose if I take an example as I cost 11 and if I write a condition as a while I less than or equal to 5 assume that I have some instructions in this will the loop be executed even once as for the condition I is 1111 less than equal to 5 false false and since it’ll quit so here the value of I will not allow you to is equal to loop even once when the condition is false in the first instance let me try the same with the do-while loop let me assume I equal to 11 place the keyword do and then I’ll say while I less than equals to 5 now I believe that our is 11 and condition 11 less than equal to five will definitely be false we are very much assured that a value of I is actually Falls in this case but still the loop exude the statements at least once which means that when the loop is false for the first time your wily will not have execution no execution if the loop if the condition is false in the first instance whatever as here the loop gets executed at least once the loop gets executed it leads to once when this condition is false even though at the first exhibition self that is the actual and the core difference between a while and do-while you remember the three difference which occurred at a were the place of the condition is tested the condition is tested at the beginning of the loop whereas in a in a do-while loop the condition is set here at the envelope in a while loop it is called as a entry control loop whereas in a do-while loop it is called as an exit control loop since the control of the loop is a descendant of the beginning it is called as an entry in a do-while the control is a decided at the end Swensen is called as a exit control group what if the condition is false to the first execution why loop will not perform any execution whereas do I will at least perform one operation now these are the three major differences apart from this we have some more differences now let us identify these differences further before the difference now what if I have a while loop followed by a condition say now hear this semicolon within a do-while at the end of the keyword a while with the condition is asked for the syntax as for the rules of syntax you have to place a semicolon at the end of the keyword awhile so that it will go back to the keyword new putting a semicolon at the end of while in a while loop is it the error no it’s not an event but there will be a different equation many people might say that this is an error most of the time when you are practicing these programs for the first time traditionally it becomes a habit to put a semicolon at the end of every instruction we might go for placing a semicolon at the end of while loop but do remember if I try such code we really enter into infinite looping how we say without the semicolon there is a traditional vertical execution of the code so it means that here the condition is tested it says true go inside and then come back and recheck the condition this is a traditional vertical execution but if a place a semicolon then in that case the loop is said to begin and end at this place so this is my begin and the same point is my endpoint what it does is it will now go in a horizontal execution so suppose if I believe that I is 1 1 less than equal to find true if this is true it says again go back and do the same condition so we say that the loop gets tacked up in this condition itself the loop goes into a horizontal mode of execution where the condition makes the loop to get stacked up and the same a point which is stated as begin as well as end if it is if it is no semicolon then it will go in this fashion if it is semicolon then it will make the loop things you could horizontally this is one of the minor differences which make a while and do-while differentiable a semicolon at the end of the condition with why in a while makes the loop exit horizontally whereas a semicolon at the end of do-while within a keyword while will make the loop to execute it vertically and it is as per syntax for itself right these are some of the major differences which exist should do I suppose if you want to add up some additional conditions what you can do is you can place that the syntax for both you can you can remember the flowchart which are draw for both while and do-while you can have some additional differences like example and finally the last difference is the working of this particular while under 1 these are the additional content switching in place as a comparison on while and what right let me summarize this first difference is about the place of the condition in a while it is at the beginning in urdu while it is at the end while is called as a entry control loop do-while is called as exit control room if condition is false in the first instance of I will not work even once do I will work at least once a semicolon at the end of the condition with Y makes the loop because you go to horizontally and semi-cool or the end of the condition with the while is asked for the syntax rules additional points which you can add up for differentiating while and dua is to place the syntax of both place the flowchart of both place the example and a brief working of both these examples these are some references which are suppose remember for while and while I again repeat at the end of every video make sure that you pause it rewrite the entire contents which appear on the screen on a piece of paper so that you can reproduce at the later stage rather than again moving the entire video thank you

2 thoughts on “While and Do While Loop Comparison – Control Statements – C Programming Language – First Year Engg”

  1. Hello Friends,
    Watch Complete Video Series of Subject Structured Programming Approach in C Programming only on Ekeeda Application.
    Use Coupon Code "FIRSTTIME" and access any one Subject for Complete one month free.
    Download Ekeeda Application and take advantage of this offer.
    Android:- https://play.google.com/store/apps/details?id=student.ekeeda.com.ekeeda_student&hl=en
    iOS:- https://itunes.apple.com/tt/app/ekeeda/id1442131224

Leave a Reply

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