DEV Community

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

Posted on

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

DAY - 04

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 :-

Question.

Two numbers are given, print their product
Two numbers are given a and b, print a-b
Print 6*3 in output, don’t print 18, just 6*3 should be in the output screen.

All the code is presented in all language.( Go to Github repository ).

Topic :-

If Else :-

The if statement is a fundamental control structure in programming that allows you to execute certain blocks of code conditionally based on the evaluation of a boolean expression. The if statement is often followed by an optional else block, which allows you to define an alternative block of code to be executed if the condition in the if statement evaluates to false.
Here's a general explanation of how the if and else statements work:
Syntax:
Java:

if (condition) {
// code to be executed if the condition is true
} else {
// code to be executed if the condition is false
}

Python:

if condition:
# code to be executed if the condition is true
else:
# code to be executed if the condition is false

C++:

if (condition) {
// code to be executed if the condition is true
} else {
// code to be executed if the condition is false
}

Kotlin:

if (condition) {
// code to be executed if the condition is true
} else {
// code to be executed if the condition is false
}

Condition: The if statement starts with a condition enclosed within parentheses. This condition is evaluated to either true or false.
True Block: If the condition evaluates to true, the block of code immediately following the if statement is executed.
False Block (Optional): If an else block is present, and the condition in the if statement evaluates to false, the block of code immediately following the else statement is executed.

Java:

int x = 10;
if (x > 5) {
System.out.println("x is greater than 5");
} else {
System.out.println("x is not greater than 5");
}

Python:
x = 10

if x > 5:
print("x is greater than 5")
else:
print("x is not greater than 5")

C++:

int x = 10;

if (x > 5) {
cout << "x is greater than 5" << endl;
} else {
cout << "x is not greater than 5" << endl;
}

Kotlin:
val x = 10

if (x > 5) {
println("x is greater than 5")
} else {
println("x is not greater than 5")
}

Now we use multiple condition with else if()

Feel free to share this post to enhance awareness and understanding of these fundamental concepts in statistical analysis!

πŸ™ 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)