DEV Community

Cover image for Day 11: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin! ๐Ÿš€
Nitin-bhatt46
Nitin-bhatt46

Posted on

Day 11: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin! ๐Ÿš€

DAY - 11

Todayโ€™s Learning :-

For more Tech content Join us on linkedin click here

All the code snippets in this journey are available on my GitHub repository. ๐Ÿ“‚ Feel free to explore and collaborate: Git Repository

1: Temperature Range: Write a program that checks if a given temperature is suitable for swimming. If the temperature is between 70 and 90 (Excluded) degrees Fahrenheit print yes, else NO.
( temperature_range )

2: Even and Positive Number: Write a program that prints โ€œYESโ€ if a given number is both even and positive, otherwise it will print โ€œNOโ€.
(pos_even )

3: Age Check: Implement a program that checks if a person is a teenager. A teenager is someone whose age is between 13 and 19 (inclusive). ( teen_age )

4: Take three numbers a,b,c from the user, print yes if a is either greater than b or c. Otherwise print NO. ( three_num )

5: What will be the result below according to the precedence table.

2*3-48==5/4*6
6<2-4*8/2
5>4<3/2-8%4+5
14-8+92>2+70
Enter fullscreen mode Exit fullscreen mode

The while and do-while loops are control flow structures in programming languages that allow you to execute a block of code repeatedly as long as a specified condition is true. Here's a brief explanation of each:
while Loop:

The while loop repeatedly executes a block of code as long as the specified condition is true. It consists of a condition and a block of code. Before each iteration, the condition is evaluated. If the condition is true, the code inside the loop is executed. The loop continues to execute until the condition becomes false.
while condition:

# code block to be executed
Enter fullscreen mode Exit fullscreen mode

do-while Loop:
The do-while loop is similar to the while loop, but the condition is evaluated at the end of the loop iteration. This means that the block of code is executed at least once, regardless of whether the condition is true or false. After each iteration, the loop continues to execute.

syntax

do {
// code block to be executed
} while (condition);

Key Differences:

In the while loop, the condition is evaluated at the beginning of each iteration. If the condition is false initially, the loop may not execute at all.
In the do-while loop, the condition is evaluated at the end of each iteration. This guarantees that the code block is executed at least once, even if the condition is false initially.

Both loops are useful for situations where you need to execute a block of code repeatedly until a certain condition is met. The choice between while and do-while depends on whether you want the code block to execute at least once or not.

In real-life coding we mostly use for and while loop only.
Feel free to reshare this post to enhance awareness and understanding of these fundamental concepts.
Code snippets are in Git repository.

๐Ÿ™ Thank you all for your time and support! ๐Ÿ™
Don't forget to catch me daily at 10:30 Am (Monday to Friday) for the latest updates on my programming journey! Let's continue to learn, grow, and inspire together! ๐Ÿ’ปโœจ

Top comments (0)