0% found this document useful (0 votes)
3 views11 pages

C# Basic - Looping Statement

The document provides an overview of looping statements in C#, explaining their purpose and types, including counter loops and conditional loops. It details the different types of loops available in C#, such as for loops, while loops, and do-while loops, along with their syntax and use cases. The document emphasizes the importance of loops for code repetition to avoid redundancy in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views11 pages

C# Basic - Looping Statement

The document provides an overview of looping statements in C#, explaining their purpose and types, including counter loops and conditional loops. It details the different types of loops available in C#, such as for loops, while loops, and do-while loops, along with their syntax and use cases. The document emphasizes the importance of loops for code repetition to avoid redundancy in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

C# Basic- Looping Statement

By Dhananjay Masal– CODEMIND Technology

Contact us +91 9890217463

1
Loops in C#:

- Loops are also called repeating statements or iterative


statements.
- also called Iteration Statements
- Looping in programming languages is a feature that facilitates
the execution of a set of instructions repeatedly while some
condition evaluates to true.
- The process of repeatedly executing a statement or group of
statements until the condition is satisfied is called looping

2
Loops

- Counter Loops are the loops, which execute a specific set


of instructions a certain number of times.
- Conditional Loops are the loops, which execute a specific
task until the condition is true.

3
Why do we need looping?

- The basic purpose of the loop is code repetition. So, whenever


the repetitions are required, then in place of writing the
statements, again and again, we need to go for looping.
- Types of Loops in C#
- For loop
- For Each Loop
- While loop
- Do while loop

4
While Loop in C# with Examples

A while loop is used for executing a statement repeatedly until a given condition returns false

while(condition) {

statements;

5
6
Do While Loop in C# with Examples

- do-while loop is a post-tested loop or exit-controlled loop i.e. first it will execute the loop
body and then it will be going to test the condition. That means we need to use the do-while
loop where we need to execute the loop body at least once.
- do {
- statements;
- }while(condition);

7
8
For Loop in C# with Examples

If we know the number of times, we want to execute some set of statements or instructions, then we should use
for loop. For loop is known as a Counter loop.

for(initialization; condition; increment/decrement){

//statements

9
10
Thank You

Success is not a milestone, it's a journey. And we have


vowed to help you in yours.

www.codemindtechnology.com
11

You might also like