Outcomes
In here you can learn while repetition statement, for repetition statement, do…while repetition statement. Also you can learn break and continue statements, counter-controlled and sentinel-controlled repetitions. So let’s start repetition structure in C programming.

Repetition Structure in C programming
In conclusion known as iteration. If the user want to repeat some action while the condition remains true, user can use this structure.
- Counter -Controlled Repetition
In short we can say in here the number of repetitions is know before the loop begins execution. Because a control variable is used to count the number of repetitions. After that the repetition terminates when the counter exceeds number of repetitions.
- Sentinel-Controlled repetition
When no indication is given of how many times the loop should execute, a sentinel value is used to terminate the loop. For example type -1 to terminate entering of marks. A loop should have a statement to obtain data each time the loop is performed.
Repetition Structure : While Statement
In the below shows the format of a while statement.
while( condition ) {
statements
}
In the body of the while statement may contain single or many statements. For example,

Let’s see the answer of the above code.

Okay let’s see another example.
Quiz 01 – Get the marks of 10 students from the keyboard and calculate the total and the average. (You can use repl.it to do your program )

Do you have any problems in variables and other parts of this code. You can refer Selection Control Structure and C programming beginning posts. Let’s see the output of the above quiz.

Repetition Structure : for Statement
Let’s see the format of the for statement.
for( expression 1 ; expression 2; expression 3 ){
statements
}
Expression in the for statement’s header are optional. So let’s see the general format .

Let’s see an example. for( i = 0; i < 5; i++ ) , In here integer value “i” started from 0 and it repeated 5 times. Increment expression acts like a standalone statement. because it is in the statement’s header.
In the statement’s header, first you have to declare a variable. if you don’t need that leave a blank. like for( ; i < 5; i++ ). In the expression 2 you have to give the condition you want. If you don’t have this also, leave a blank. like for( ; ; i++ ).
In the expression 3, you have to give the increment statement. If don’t have this also, you can leave a blank. like for( ; ; ). It means for( ; ; ) also the correct header. But this is not correct in coding. You must give the expressions into for statement’s header. If you try to leave blanks in the code, it will give you an warning messages.

try to do this quiz, use a c online compiler.
Quiz 02 – Write a program that will print the following sequence of value( hint use a for loop ) sequence – 3, 8, 13, 18, 23

Repetition Structure : do…while Statement
In this statement loop continuation condition is checked after the loop body is performed. Therefore the loop body will be executed at least once. Let’s see the format,
do{
statements
}while( condition );
see the example in the below, you can get an idea of do…while statement. get the output with your own in the compiler.

Repetition Structure in C programming : Break Statement
The break statement is executed in while, for, do…while, statements to exit from that statement. After that program execution continues with the next statement. See the example given below.

Repetition Structure in C programming : Continue Statement
This also executed in while, for and do…while statements. In this statement skips the remaining statements in the body of that control statement and do the next iteration. see the example given below.

Repetition Structure : Nested Iteration Statement
Now you know the iterations. In this statement we are going to use that iterations as nested. See the example given below,

Let’s see the output,

So this is the end of this post. If you have any problems Contact us.
Thank you. Make sure to leave a comment.
There are more articles from BuildITMasters. Follow the below link to refer.
- Selection Control Structure | C programming
- File Handling & Pointers | C programming – Click here to refer
Other articles from different categories.
- Android Studio Articles – https://builditmasters.com/category/android-studio/
- Android Studio Firebase Tutorial – https://builditmasters.com/category/android-studio-firebase-tutorial/
- C Programming – https://builditmasters.com/category/programming/
- Flutter – https://builditmasters.com/category/flutter/
- GitHub Tutorials – https://builditmasters.com/category/github/
- Java Programming – https://builditmasters.com/category/java-programming/
- MERN / MEVN Stacks – https://builditmasters.com/category/mern_mevn_stacks/
- Tech News – https://builditmasters.com/category/tech-news/
- Theory Lessons – https://builditmasters.com/category/theory-lessons/
- Adobe Tutorials – https://builditmasters.com/category/adobe-tutorials/
- Best Website for Programming – https://builditmasters.com/category/best-website-for-programming/
- Different Programming Styles – https://builditmasters.com/category/different-programming-styles/
- Earn Money – https://builditmasters.com/category/earn-money/
- Social Word – https://builditmasters.com/category/social-world/