UPSC Exam  >  UPSC Questions  >  Name the types of looping statements availabl... Start Learning for Free
Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example?
Most Upvoted Answer
Name the types of looping statements available in c language. deffernt...
Types of Looping Statements in C Language
In C language, there are primarily three types of looping statements:
- for loop
- while loop
- do...while loop
Each of these loops allows for repeated execution of a block of code based on a condition.
Difference Between For Loop and Do...While Loop
1. Syntax
- For Loop:
The for loop starts with the initialization of a variable, checks the condition, and then executes the block of code.
c
for (initialization; condition; increment/decrement) {
// Code to be executed
}
- Do...While Loop:
The do...while loop executes the block of code before checking the condition, ensuring that the code runs at least once.
c
do {
// Code to be executed
} while (condition);
2. Execution Flow
- For Loop:
- Initializes a counter.
- Checks the condition before executing the block.
- If the condition is false initially, the block may never execute.
- Do...While Loop:
- Executes the block first, then checks the condition.
- Guarantees that the block runs at least once, regardless of the condition.
Example
- For Loop Example:
c
for (int i = 0; i < 5;="" i++)="" />
printf("%d ", i); // Output: 0 1 2 3 4
}
- Do...While Loop Example:
c
int i = 0;
do {
printf("%d ", i); // Output: 0 1 2 3 4
i++;
} while (i < />
Conclusion
In summary, the key difference lies in the execution order and the guarantee of code execution. The for loop checks conditions before execution, while the do...while loop ensures execution at least once.
Explore Courses for UPSC exam

Top Courses for UPSC

Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example?
Question Description
Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? for UPSC 2024 is part of UPSC preparation. The Question and answers have been prepared according to the UPSC exam syllabus. Information about Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? covers all topics & solutions for UPSC 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example?.
Solutions for Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? in English & in Hindi are available as part of our courses for UPSC. Download more important topics, notes, lectures and mock test series for UPSC Exam by signing up for free.
Here you can find the meaning of Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? defined & explained in the simplest way possible. Besides giving the explanation of Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example?, a detailed solution for Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? has been provided alongside types of Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? theory, EduRev gives you an ample number of questions to practice Name the types of looping statements available in c language. defferntiate between for loop and do..while loop with suitable example? tests, examples and also practice UPSC tests.
Explore Courses for UPSC exam

Top Courses for UPSC

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev