Simple do while programs
The do.. The body of do Only then, the test expression is evaluated. Here, we have used a do The loop works as long as the input number is not 0. The do The condition is checked only after the first iteration has been executed. So, if the first input is a non-zero number, that number is added to the sum variable and the loop continues to the next iteration. This process is repeated until the user enters 0. But if the first input is 0, there will be no second iteration of the loop and sum becomes 0.
Course Index Explore Programiz. Popular Tutorials Data Types in C. C for Loop. Arrays in C Programming. Here the first line gets printed without checking the condition. It only happens in the do-while loop. Q1- Write a program to show the working of the do-while loop. Q2- Print the table in descending order of 10 using the do-while loop. If you use a do-while loop inside another do-while loop, it is known as nested do-while loop. The nested do-while loop is executed fully for each outer do-while loop.
Ankit Lathiya is a Master of Computer Application by education and Android and Laravel Developer by profession and one of the authors of this blog. Packages in Java. Flow Control in Java. Loops in Java. Jump Statements in Java. Arrays in Java. Strings in Java.
OOPS in Java. Constructors in Java. Interfaces in Java. Keywords in Java. Remove Numbers from String. Compare two Dates. Serialization and Deserialization. Java Library Functions. Basics Of Digital Components. Types of Computer Networks. Classical Synchronization Problem. What are Semaphores? Do while loop is used when the actual code must be executed atleast once. For example: Incase of menu driven functions.
Learn CSS. Learn JavaScript. C Language C Tutorial. C Compiler. Standard Template Library.
0コメント