DEV Community

Cover image for Day 12: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin!
Nitin-bhatt46
Nitin-bhatt46

Posted on

Day 12: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin!

DAY - 12

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

Today’s Learning :-

1: Take a number n from the user and print all the even numbers between 1 and n(inclusive). Do this using a while loop.
( while_even )

2: Find the factorial of a number n using a while loop. ( fac_while )

3: Given a number n, print all the numbers from 1 to n(inclusive) which are not divisible by 3 and 5. (use Continue here). ( con_div )

4: Given a number n, print the corresponding month of it. For n=1, print Jan, n=2, print Feb…, if the user puts any invalid number, don’t do anything. (Use switch here) ( mon_switch )

5: Print all the Capital and small letters using a while loop. It means A-Z, then a-z.

The switch statement in programming languages is a control flow statement that allows you to select one of many code blocks to be executed based on the value of a variable or expression. It provides an alternative to using multiple if...else if...else statements when you have to choose between several mutually exclusive options.
Here's the basic syntax of a switch statement:
switch (expression) {
case value1:
// code block to be executed if expression equals value1
break;
case value2:
// code block to be executed if expression equals value2
break;
// More case statements for other values
default:
// code block to be executed if none of the above cases are true
}

The switch expression is evaluated once.

The case labels specify values to match against the expression.
When a match is found, the corresponding code block is executed until a break statement is encountered.
The default case is optional and is executed if no match is found.
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)