The document discusses different types of loops in programming languages. It defines looping as repetitively executing a sequence of statements, which is an important concept that allows programs to repeat tasks. There are two main types of loops - entry controlled loops where the test condition is checked before the loop body executes, and exit controlled loops where the test is checked after execution. Common loops in C include the for, while, and do-while loops. The for loop is entry controlled and uses a counter variable, while the while and do-while can use counters or sentinel values and are entry and exit controlled respectively. Selecting the right loop depends on pre-test or post-test needs as well as whether the number of repetitions is known.
The document discusses various decision making and looping statements in C programming. It describes simple if, if-else, nested if, nested else-if ladder, and switch statements for decision making. It also covers while, do-while, and for loops for repetitive execution of code. Specific examples are provided for each statement type to illustrate their syntax and usage.
1) The document discusses different types of flow control in programming, including sequential, selection, and iteration.
2) Selection flow control, also called conditional execution, allows selecting one of two blocks to execute based on a condition. Only one block is executed.
3) The main selection statements in C++ are if-else and switch. If-else allows for conditional execution based on a Boolean test, while switch allows selecting a code block based on equality to integer or character constants.
Thank you for the detailed document on control flow statements in C programming. I appreciate you taking the time to explain these concepts. Please let me know if you have any other questions!
The document discusses conditional statements in programming. Conditional statements check an expression and execute code depending on whether the expression is true or false. The main conditional statements are IF statements and IF-ELSE statements. An IF statement executes code if the expression is true, while an IF-ELSE statement executes the IF code if true and the ELSE code if false. Examples are provided to illustrate how to use IF and IF-ELSE statements to check conditions and produce different outputs.
The document discusses different types of selection and looping constructs in imperative programming languages. It describes if-else statements, switch-case statements, and how they allow a program to select different courses of action based on conditions. It also covers while, for, and do-while loops and how they repeatedly execute blocks of code while or until certain conditions are met. Examples are provided for each type of construct to illustrate their syntax and usage.
This document discusses different types of decision making statements in Java including if, if-else, if-else-if, nested if, and switch statements. It provides the syntax and flow for each statement type along with examples to demonstrate their usage. Key aspects covered include using boolean expressions to determine program flow, nesting if statements, using break to terminate switch cases, and applying the switch statement to variables of specific data types only.
This document discusses different types of decision making statements in Java including if, if-else, if-else-if, nested if, and switch statements. It provides the syntax and flow for each statement type along with examples to demonstrate their usage. Key decision making structures covered are basic if statements with conditional blocks, if-else statements that execute alternative code blocks based on boolean expressions, and if-else-if statements that allow testing multiple conditions in a single structure. The document also reviews nested if statements, switch statements for equality checks, and rules that apply to switch statements.
This document provides information about various flow control constructs in C++ including sequence, selection, and iteration. It discusses the if, if-else, nested if, switch, and ternary operator constructs for selection. It also covers for, while, and do-while loops for iteration. Examples are given for if, if-else, switch, and a calculator program using nested ifs. The differences between if-else and switch are explained.
Switch statement, break statement, go to statementRaj Parekh
The document discusses various control flow statements in C programming including switch case statement, break statement, and goto statement. It provides the syntax and meaning of switch case statement which allows executing different code blocks based on the value of an expression. It also explains the break statement which terminates the execution of a switch case or loop statement. The goto statement allows transferring program control unconditionally to another label in the program.
This document discusses various program flow control statements in Java, including selection statements (if, if-else, switch), iteration statements (for, while, do-while), and jump statements (return, break, continue). It provides examples and comparisons of these statements. The document is intended as teaching material, as it includes sections on classwork, homework, and was created by an instructor.
The document discusses different types of conditional branching statements in C#, including if, if/else, and switch statements. The if statement executes code if a conditional statement is true, while if/else allows specifying alternate code for when it's false. A switch statement can replace multiple if/else statements by checking multiple potential cases. The goto statement shifts execution to a labeled part of the code.
The document discusses different decision making statements in C programming including if, if-else, nested if-else, if-else-ladder, and switch case statements. The if statement executes code if a condition is true, while if-else adds an else block to also handle when the condition is false. Nested if statements allow if blocks within other if blocks. If-else-ladder checks multiple conditions in order. Switch case allows different code blocks based on the value of a variable. Flow diagrams and syntax are provided for each statement type.
Decision Making in Java (if, if-else, switch, break, continue, jump) Decision Making in programming is similar to decision making in real life. A programming language uses control statements to control the flow of execution of program based on certain conditions.
The document discusses different types of selection statements in C programming including if statements, else if statements, nested if statements, switch statements, and nested switch statements. It provides the syntax and examples of how to use each type of statement to control program flow based on logical expressions that evaluate to true or false. The if statement and switch statement allow executing different blocks of code conditionally based on the result of logical expressions or comparisons.
The document discusses various Python flow control statements including if/else, for loops, while loops, break and continue. It provides examples of using if/else statements for decision making and checking conditions. It also demonstrates how to use for and while loops for iteration, including using the range function. It explains how break and continue can be used to terminate or skip iterations. Finally, it briefly mentions pass, for, while loops with else blocks, and nested loops.
This document discusses different types of branching and decision making statements in C language, including if, else if, switch, and goto statements. It provides the syntax and usage for each statement type. The if statement allows for conditional execution of code based on expression evaluations. Else if statements allow for chained conditional checks. Switch statements allow selecting between multiple cases. Goto statements allow unconditional jumps in code. Nesting is also supported to allow for complex conditional logic.
The document discusses different control statements in C programming language that allow changing the order of execution of statements based on conditions. It describes the if-else statement, which executes one block of code if the test expression is true and another block if it is false. It also covers nested if-else statements with multiple conditions, the if-else-if ladder for choosing among multiple paths, the goto statement for unconditional jumps, and the switch case statement for equality checks against a list of case values. Examples and flowcharts are provided to illustrate the logic and usage of each control statement.
The document discusses various Java control structures including boolean variables, if and if-else statements, and switch statements. It explains:
- Boolean variables store true/false values and are used to make conditional decisions in control structures.
- If statements allow executing code conditionally based on boolean expressions. If-else statements choose between two code blocks.
- Switch statements select code blocks based on an integer or character value using case labels.
- Nesting, boolean operators, and precedence rules allow complex conditional logic.
The document discusses different types of loops in Java including while, do-while, and for loops. It explains the syntax and flow of each loop type and provides examples of how and when to use each loop. The document also covers break and continue statements that can be used inside loops to control flow, as well as increment and decrement operators.
Chapter 2 : Programming with Java StatementsIt Academy
Exam Objective 4.1 Describe, compare, and contrast these three fundamental types of statements: assignment, conditional, and iteration, and given a description of an algorithm, select the appropriate type of statement to design the algorithm
This document provides an overview of different types of statements and flow control constructs in C++ programming. It discusses sequential, selection, and iteration statements. Selection statements covered include if, if-else, switch, and ternary operator. Iteration statements discussed are for, while, do-while, and nested loops. Jump statements like break, continue, goto, and exit function are also summarized. Examples are provided for most constructs to illustrate their usage.
The document discusses the three types of loops in Java - while loops, do-while loops, and for loops. While loops repeat as long as a boolean expression is true. Do-while loops execute the code block at least once before checking the boolean expression. For loops allow efficient repetition when the number of iterations is known. Code examples are provided to illustrate the usage of each loop type.
This document discusses Java control statements including if/else, switch, while, do-while, for loops, break, continue, return, and labeled break/continue. If/else and switch are used for conditional execution. While, do-while and for loops are used for repetitive execution until a condition is met. Break exits the current loop, continue skips to the next iteration. Return exits the current method. Labeled statements allow breaking or continuing from a specific nested loop.
This document discusses different types of loops in Java programming: while, for, do-while, and enhanced for loops. It provides the syntax and flow for each loop type along with examples. The key loop types are:
- While loops repeat while a condition is true, testing at the start of each iteration.
- For loops iterate a specific number of times, with initialization, condition, and update sections.
- Do-while loops are like while loops but test the condition at the end, so the body executes at least once.
- Enhanced for loops iterate over collections/arrays, declaring a block variable to access each element.
Loops allow blocks of code to be repeatedly executed. The three types of loops in C are while loops, for loops, and do-while loops. While loops check the condition before each iteration. For loops allow initialization, condition checking, and increment/decrement in the loop header. Do-while loops check the condition after executing the block at least once. Break and continue statements can be used to exit or skip portions of loops. Switch statements compare a value to multiple case values and execute the corresponding block.
This document discusses different types of decision making statements in Java including if, if-else, if-else-if, nested if, and switch statements. It provides the syntax and flow for each statement type along with examples to demonstrate their usage. Key aspects covered include using boolean expressions to determine program flow, nesting if statements, using break to terminate switch cases, and applying the switch statement to variables of specific data types only.
This document discusses different types of decision making statements in Java including if, if-else, if-else-if, nested if, and switch statements. It provides the syntax and flow for each statement type along with examples to demonstrate their usage. Key decision making structures covered are basic if statements with conditional blocks, if-else statements that execute alternative code blocks based on boolean expressions, and if-else-if statements that allow testing multiple conditions in a single structure. The document also reviews nested if statements, switch statements for equality checks, and rules that apply to switch statements.
This document provides information about various flow control constructs in C++ including sequence, selection, and iteration. It discusses the if, if-else, nested if, switch, and ternary operator constructs for selection. It also covers for, while, and do-while loops for iteration. Examples are given for if, if-else, switch, and a calculator program using nested ifs. The differences between if-else and switch are explained.
Switch statement, break statement, go to statementRaj Parekh
The document discusses various control flow statements in C programming including switch case statement, break statement, and goto statement. It provides the syntax and meaning of switch case statement which allows executing different code blocks based on the value of an expression. It also explains the break statement which terminates the execution of a switch case or loop statement. The goto statement allows transferring program control unconditionally to another label in the program.
This document discusses various program flow control statements in Java, including selection statements (if, if-else, switch), iteration statements (for, while, do-while), and jump statements (return, break, continue). It provides examples and comparisons of these statements. The document is intended as teaching material, as it includes sections on classwork, homework, and was created by an instructor.
The document discusses different types of conditional branching statements in C#, including if, if/else, and switch statements. The if statement executes code if a conditional statement is true, while if/else allows specifying alternate code for when it's false. A switch statement can replace multiple if/else statements by checking multiple potential cases. The goto statement shifts execution to a labeled part of the code.
The document discusses different decision making statements in C programming including if, if-else, nested if-else, if-else-ladder, and switch case statements. The if statement executes code if a condition is true, while if-else adds an else block to also handle when the condition is false. Nested if statements allow if blocks within other if blocks. If-else-ladder checks multiple conditions in order. Switch case allows different code blocks based on the value of a variable. Flow diagrams and syntax are provided for each statement type.
Decision Making in Java (if, if-else, switch, break, continue, jump) Decision Making in programming is similar to decision making in real life. A programming language uses control statements to control the flow of execution of program based on certain conditions.
The document discusses different types of selection statements in C programming including if statements, else if statements, nested if statements, switch statements, and nested switch statements. It provides the syntax and examples of how to use each type of statement to control program flow based on logical expressions that evaluate to true or false. The if statement and switch statement allow executing different blocks of code conditionally based on the result of logical expressions or comparisons.
The document discusses various Python flow control statements including if/else, for loops, while loops, break and continue. It provides examples of using if/else statements for decision making and checking conditions. It also demonstrates how to use for and while loops for iteration, including using the range function. It explains how break and continue can be used to terminate or skip iterations. Finally, it briefly mentions pass, for, while loops with else blocks, and nested loops.
This document discusses different types of branching and decision making statements in C language, including if, else if, switch, and goto statements. It provides the syntax and usage for each statement type. The if statement allows for conditional execution of code based on expression evaluations. Else if statements allow for chained conditional checks. Switch statements allow selecting between multiple cases. Goto statements allow unconditional jumps in code. Nesting is also supported to allow for complex conditional logic.
The document discusses different control statements in C programming language that allow changing the order of execution of statements based on conditions. It describes the if-else statement, which executes one block of code if the test expression is true and another block if it is false. It also covers nested if-else statements with multiple conditions, the if-else-if ladder for choosing among multiple paths, the goto statement for unconditional jumps, and the switch case statement for equality checks against a list of case values. Examples and flowcharts are provided to illustrate the logic and usage of each control statement.
The document discusses various Java control structures including boolean variables, if and if-else statements, and switch statements. It explains:
- Boolean variables store true/false values and are used to make conditional decisions in control structures.
- If statements allow executing code conditionally based on boolean expressions. If-else statements choose between two code blocks.
- Switch statements select code blocks based on an integer or character value using case labels.
- Nesting, boolean operators, and precedence rules allow complex conditional logic.
The document discusses different types of loops in Java including while, do-while, and for loops. It explains the syntax and flow of each loop type and provides examples of how and when to use each loop. The document also covers break and continue statements that can be used inside loops to control flow, as well as increment and decrement operators.
Chapter 2 : Programming with Java StatementsIt Academy
Exam Objective 4.1 Describe, compare, and contrast these three fundamental types of statements: assignment, conditional, and iteration, and given a description of an algorithm, select the appropriate type of statement to design the algorithm
This document provides an overview of different types of statements and flow control constructs in C++ programming. It discusses sequential, selection, and iteration statements. Selection statements covered include if, if-else, switch, and ternary operator. Iteration statements discussed are for, while, do-while, and nested loops. Jump statements like break, continue, goto, and exit function are also summarized. Examples are provided for most constructs to illustrate their usage.
The document discusses the three types of loops in Java - while loops, do-while loops, and for loops. While loops repeat as long as a boolean expression is true. Do-while loops execute the code block at least once before checking the boolean expression. For loops allow efficient repetition when the number of iterations is known. Code examples are provided to illustrate the usage of each loop type.
This document discusses Java control statements including if/else, switch, while, do-while, for loops, break, continue, return, and labeled break/continue. If/else and switch are used for conditional execution. While, do-while and for loops are used for repetitive execution until a condition is met. Break exits the current loop, continue skips to the next iteration. Return exits the current method. Labeled statements allow breaking or continuing from a specific nested loop.
This document discusses different types of loops in Java programming: while, for, do-while, and enhanced for loops. It provides the syntax and flow for each loop type along with examples. The key loop types are:
- While loops repeat while a condition is true, testing at the start of each iteration.
- For loops iterate a specific number of times, with initialization, condition, and update sections.
- Do-while loops are like while loops but test the condition at the end, so the body executes at least once.
- Enhanced for loops iterate over collections/arrays, declaring a block variable to access each element.
Loops allow blocks of code to be repeatedly executed. The three types of loops in C are while loops, for loops, and do-while loops. While loops check the condition before each iteration. For loops allow initialization, condition checking, and increment/decrement in the loop header. Do-while loops check the condition after executing the block at least once. Break and continue statements can be used to exit or skip portions of loops. Switch statements compare a value to multiple case values and execute the corresponding block.
This document discusses different types of loops in C programming. It describes while, for, do-while, and nested loops. While loops execute a block of code as long as a condition is true. For loops allow executing a block of code a specific number of times. Do-while loops are similar to while loops but execute the block at least once even if the condition is false. Nested loops allow a loop to be placed inside another loop to repeat a block of code multiple times.
C++ provides several types of loops to repeat blocks of code, including while, for, do-while, and nested loops. Loop control statements like break, continue, and goto change the normal execution flow. An infinite loop is one whose condition never becomes false, allowing the loop to repeat indefinitely until terminated.
#loops, #c, #program, #loops in c, #c loops, #loops introduction, #while and do while loop, #for loop in c programming, #loops in c programming, #c programming loop, #c loop programs, #looping structure in c, #looping
This document discusses loops in C++ programming. It defines while, for, and do-while loops and how each one works. It also describes loop control statements like break, continue, and goto that change the normal execution of loops. Finally, it provides an example of an infinite loop in C++ using a for loop without a conditional expression to repeat indefinitely.
This document discusses different types of loops in computer programming including for, while, and do-while loops. It provides definitions and descriptions of each loop type, their syntax, and how they work. Nested loops are also covered, which are loops used inside other loops. Key details covered include how for loops iterate with a loop variable, while loops test conditions before executing, and do-while loops check conditions at the bottom of the loop so they always execute at least once.
“Loop in C – Properties, and Applications”. We will cover Introduction, Details, Advantages, History, Types of Loops, Flowcharts, Practical Use, Outputs, and Conclusion. What is a loop? We are all familiar with the idea of listening to songs on loops. But, we are obviously not here to speak on that.
What is a loop in C? Looping Statements in C execute the sequence of statements many times until the stated condition becomes false. It has mainly 2 parts – a body of a loop and a control statement. The main purpose is to repeat the same code a number of times.
This presentation educates you about R-loops with the following general form of a loop statement in most of the programming languages, Loop Type & Description, Loop Control Statements, Control Statement & Description.
For more topics stay tuned with Learnbay.
Visual Basic loop structures allow you to run one or more lines of code repetitively. You can repeat the statements in a loop structure until a condition is True, until a condition is False, a specified number of times, or once for each element in a collection.
This document discusses different types of looping statements in C++ including while, do-while, and for loops. It explains the syntax and flow of each loop. While and do-while loops evaluate a condition before or after executing the loop body. For loops allow pre-determining the number of iterations using initialization, condition testing, and incrementing/decrementing of a control variable. The document also covers jump statements like goto, break, continue and exit() which can transfer program control within and between loops and functions.
This document discusses control statements and decision making in C programming. It describes the different types of conditional statements like if, if-else, if-else-ladder statements. It also covers loops like while, for, do-while loops and their syntax. Finally, it discusses single line and multi-line comments in C with examples.
This document discusses different types of loop constructs in C programming language. It describes while, do-while and for loops. While and do-while loops execute statements repeatedly as long as a given condition is true. For loops allow initialization of counters, check a condition, and update the counter each iteration. The document also covers flow charts to illustrate loop execution and examples of each loop type as well as continue, break and goto statements that change loop flow.
Loops in C# include for, while, do-while, nested, and foreach loops. For loops execute statements as long as a condition is true, evaluating the condition before each iteration. While loops also check a condition before each iteration. Do-while loops are similar but check the condition after iterating at least once. Nested loops contain one loop within another. Foreach loops iterate through each element of an enumerable collection.
The document discusses do-while loops and switch statements in C++. It provides explanations of the syntax and flow of do-while loops, including that the code block is executed at least once before the condition is checked. It also explains switch statements, including that they provide an alternative to nested if-else statements when there are multiple choices and only one should be executed. Examples are provided of using do-while loops to display numbers and switch statements to perform arithmetic operations based on an operator.
The role of the lexical analyzer
Specification of tokens
Finite state machines
From a regular expressions to an NFA
Convert NFA to DFA
Transforming grammars and regular expressions
Transforming automata to grammars
Language for specifying lexical analyzers
Passenger car unit (PCU) of a vehicle type depends on vehicular characteristics, stream characteristics, roadway characteristics, environmental factors, climate conditions and control conditions. Keeping in view various factors affecting PCU, a model was developed taking a volume to capacity ratio and percentage share of particular vehicle type as independent parameters. A microscopic traffic simulation model VISSIM has been used in present study for generating traffic flow data which some time very difficult to obtain from field survey. A comparison study was carried out with the purpose of verifying when the adaptive neuro-fuzzy inference system (ANFIS), artificial neural network (ANN) and multiple linear regression (MLR) models are appropriate for prediction of PCUs of different vehicle types. From the results observed that ANFIS model estimates were closer to the corresponding simulated PCU values compared to MLR and ANN models. It is concluded that the ANFIS model showed greater potential in predicting PCUs from v/c ratio and proportional share for all type of vehicles whereas MLR and ANN models did not perform well.
☁️ GDG Cloud Munich: Build With AI Workshop - Introduction to Vertex AI! ☁️
Join us for an exciting #BuildWithAi workshop on the 28th of April, 2025 at the Google Office in Munich!
Dive into the world of AI with our "Introduction to Vertex AI" session, presented by Google Cloud expert Randy Gupta.
The Fluke 925 is a vane anemometer, a handheld device designed to measure wind speed, air flow (volume), and temperature. It features a separate sensor and display unit, allowing greater flexibility and ease of use in tight or hard-to-reach spaces. The Fluke 925 is particularly suitable for HVAC (heating, ventilation, and air conditioning) maintenance in both residential and commercial buildings, offering a durable and cost-effective solution for routine airflow diagnostics.
Concept of Problem Solving, Introduction to Algorithms, Characteristics of Algorithms, Introduction to Data Structure, Data Structure Classification (Linear and Non-linear, Static and Dynamic, Persistent and Ephemeral data structures), Time complexity and Space complexity, Asymptotic Notation - The Big-O, Omega and Theta notation, Algorithmic upper bounds, lower bounds, Best, Worst and Average case analysis of an Algorithm, Abstract Data Types (ADT)
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYijscai
With the increased use of Artificial Intelligence (AI) in malware analysis there is also an increased need to
understand the decisions models make when identifying malicious artifacts. Explainable AI (XAI) becomes
the answer to interpreting the decision-making process that AI malware analysis models use to determine
malicious benign samples to gain trust that in a production environment, the system is able to catch
malware. With any cyber innovation brings a new set of challenges and literature soon came out about XAI
as a new attack vector. Adversarial XAI (AdvXAI) is a relatively new concept but with AI applications in
many sectors, it is crucial to quickly respond to the attack surface that it creates. This paper seeks to
conceptualize a theoretical framework focused on addressing AdvXAI in malware analysis in an effort to
balance explainability with security. Following this framework, designing a machine with an AI malware
detection and analysis model will ensure that it can effectively analyze malware, explain how it came to its
decision, and be built securely to avoid adversarial attacks and manipulations. The framework focuses on
choosing malware datasets to train the model, choosing the AI model, choosing an XAI technique,
implementing AdvXAI defensive measures, and continually evaluating the model. This framework will
significantly contribute to automated malware detection and XAI efforts allowing for secure systems that
are resilient to adversarial attacks.
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...Infopitaara
A feed water heater is a device used in power plants to preheat water before it enters the boiler. It plays a critical role in improving the overall efficiency of the power generation process, especially in thermal power plants.
🔧 Function of a Feed Water Heater:
It uses steam extracted from the turbine to preheat the feed water.
This reduces the fuel required to convert water into steam in the boiler.
It supports Regenerative Rankine Cycle, increasing plant efficiency.
🔍 Types of Feed Water Heaters:
Open Feed Water Heater (Direct Contact)
Steam and water come into direct contact.
Mixing occurs, and heat is transferred directly.
Common in low-pressure stages.
Closed Feed Water Heater (Surface Type)
Steam and water are separated by tubes.
Heat is transferred through tube walls.
Common in high-pressure systems.
⚙️ Advantages:
Improves thermal efficiency.
Reduces fuel consumption.
Lowers thermal stress on boiler components.
Minimizes corrosion by removing dissolved gases.
We introduce the Gaussian process (GP) modeling module developed within the UQLab software framework. The novel design of the GP-module aims at providing seamless integration of GP modeling into any uncertainty quantification workflow, as well as a standalone surrogate modeling tool. We first briefly present the key mathematical tools on the basis of GP modeling (a.k.a. Kriging), as well as the associated theoretical and computational framework. We then provide an extensive overview of the available features of the software and demonstrate its flexibility and user-friendliness. Finally, we showcase the usage and the performance of the software on several applications borrowed from different fields of engineering. These include a basic surrogate of a well-known analytical benchmark function; a hierarchical Kriging example applied to wind turbine aero-servo-elastic simulations and a more complex geotechnical example that requires a non-stationary, user-defined correlation function. The GP-module, like the rest of the scientific code that is shipped with UQLab, is open source (BSD license).
2. C – LOOP
There may be a situation,
when you need to execute a
block of code several number
of times. In general,
statements are executed
sequentially: The first
statement in a function is
executed first, followed by the
second, and so on.
A loop statement allows us to
execute a statement or group
of statements multiple times
and following is the general
form of a loop statement in
most of the programming
languages:
3. TYPES OF LOOP
Statement Description
1. for loop Execute a sequence of statements multiple times and
abbreviates the code that manages the loop variable.
2. while loop Repeats a statement or group of statements while a given
condition is true. It tests the condition before executing the
loop body.
3. do...while loop Like a while statement, except that it tests the
condition at the end of the loop body
4. nested loop You can use one or more loop inside any another while, for
or do..while loop.
C programming language provides the following types of loop to handle
looping requirements.
4. FOR LOOP
A for loop is a repetition control structure that allows you to
efficiently write a loop that needs to execute a specific number
of times.
Syntax:
5. FLOW OF CONTROL IN A FOR LOOP
The init step is executed first, and only once. This step allows
you to declare and initialize any loop control variables. You are
not required to put a statement here, as long as a semicolon
appears.
Next, the condition is evaluated. If it is true, the body of the loop
is executed. If it is false, the body of the loop does not execute
and flow of control jumps to the next statement just after the for
loop.
After the body of the for loop executes, the flow of control jumps
back up to the increment statement. This statement allows you
to update any loop control variables. This statement can be left
blank, as long as a semicolon appears after the condition.
The condition is now evaluated again. If it is true, the loop
executes and the process repeats itself (body of loop, then
increment step, and then again condition). After the condition
becomes false, the for loop terminates.
8. 2. WHILE LOOP
A while loop statement repeatedly executes a target
statement as long as a given condition is true.
Syntax:
Here, statement(s) may be a single statement or a block of
statements.
The condition may be any expression, and true is any nonzero
value. The loop iterates while the condition is true.
When the condition becomes false, program control passes to
the line immediately following the loop.
9. FLOW DIAGRAM: WHILE LOOP
Here, key point of the while loop is that the loop might not ever run. When the
condition is tested and the result is false, the loop body will be skipped and the
first statement after the while loop will be executed.
11. 3. DO..WHILE LOOP
Unlike for and while loops, which test the loop condition at the
top of the loop, the do...while loop in checks its condition at the
bottom of the loop.
A do...while loop is similar to a while loop, except that a
do...while loop is guaranteed to execute at least one time.
Syntax:
Notice that the conditional expression appears at the end of the
loop, so the statement(s) in the loop execute once before the
condition is tested.
If the condition is true, the flow of control jumps back up to do,
and the statement(s) in the loop execute again. This process
repeats until the given condition becomes false.
14. NESTED LOOPS IN C
It is allow to use one loop inside another loop.
The syntax for a nested for loop statement
The syntax for a nested while loop statement
15. NESTED LOOPS IN C
The syntax for a nested do...while loop
A final note on loop nesting is that you can put any type of
loop inside of any other type of loop. For example, a for loop
can be inside a while loop or vice versa.
18. LOOP CONTROL STATEMENTS:
Loop control statements change execution from its normal
sequence. C supports the following control statements.
Control Statement Description
break statement Terminates the loop or switch statement and transfers
execution to the statement immediately following the loop
or switch.
continue statement Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
19. BREAK STATEMENT
The break statement in C programming language has
the following two usages:
When the break statement is encountered inside a loop, the
loop is immediately terminated and program control resumes
at the next statement following the loop.
It can be used to terminate a case in the switch statement (we
already saw).
If you are using nested loops (i.e., one loop inside
another loop), the break statement will stop the execution
of the innermost loop and start executing the next line of
code after the block.
Syntax:
break;
23. CONTINUE STATEMENT
The continue statement works somewhat like the break
statement. Instead of forcing termination, however,
continue forces the next iteration of the loop to take
place, skipping any code in between.
For the for loop, continue statement causes the
conditional test and increment portions of the loop to
execute. For the while and do...while loops, continue
statement causes the program control passes to the
conditional tests.
Syntax:
continue;