Pre-Test Loop

Estudies4you
Pre-test Loop
With each iteration, the program executes the loops block first and tests against a condition.
If the condition is true, the loop continues and executes another iteration; if the condition is false, the loop terminates.
With a post-test loop the loop is executed at least once.
computer programming in c study material,c language study material, computer programming in c notes pdf,c language notes pdf,computer programming in c lecture notes, c language lecture notes jntu,pre test loop in c language,common expressions in loops,estudies,jntuh 1-1 study material,computer programming in c syllabus pdf
When the test takes place at the bottom of the loop, then it is a post-test loop.
In each iteration of post-test loop, the actions are executed first and then the condition is checked.
If the condition is true then the new iteration starts if not the loop terminates.

computer programming in c study material,c language study material, computer programming in c notes pdf,c language notes pdf,computer programming in c lecture notes, c language lecture notes jntu,pre test loop in c language,common expressions in loops,estudies,jntuh 1-1 study material,computer programming in c syllabus pdf
Initializing and Updating
Here, the action takes place first and then the updating of action.
After the action is updated the condition is tested.

The Comma Expression
The comma operator can be used to link related and expression together.
It is a compound expression containing two or more sub expressions separated with a comma and evaluated from left to right.
The comma expression is used in ‘for loop’ as given,
(Expression 1, expression 2, expression 3)

Example:
for(sum=0, i=1; i<20; i++)
{
scanf(“%d”, &a);
sum +=a;
} //end for

To Top