Day 10: Unveiling the Magic of INTRODUCTION in Java, C++, Python, and Kotlin! 🚀
Tags: programming, journey, learning, coding
Published: 2024-03-18 05:35:32

DAY - 10

For more Tech content Join us on  linkedin [click here](https://www.linkedin.com/in/nitin-bhatt-962356260/)


All the code snippets in this journey are available on my GitHub repository. 📂 Feel free to explore and collaborate: [Git Repository](https://github.com/Nitin-bhatt46/POWER_OF_PROGRAMMING/tree/main
)

Today’s Learning :- 

BODMAS is an acronym that stands for Brackets, Orders (exponents), Multiplication and Division (from left to right), and Addition and Subtraction (from left to right). It represents the order of operations in mathematical expressions. Let's see how it applies in Java, C++, and Python:


Java:
In Java, BODMAS rules are followed naturally due to the operator precedence defined in the language. Here's an example:

public class Bodmas{
 public static void main(String[] args) {
 int result = 5 + 3 * 2 - 4 / 2;
 System.out.println("Result: " + result); // Output: 9
 }
}

In this example, the multiplication (*) and division (/) operations take precedence over addition (+) and subtraction (-), so they are performed first, following the BODMAS rules.


C++:

Similarly, in C++, the BODMAS rules are inherent due to the operator precedence defined by the language. Here's an example:
#include <iostream>
using namespace std;

int main() {
 int result = 5 + 3 * 2 - 4 / 2;
 cout << "Result: " << result << endl; // Output: 9
 return 0;
}

As in Java, the multiplication and division operations have higher precedence than addition and subtraction, so they are performed first, following the BOMAS rules.

Python:
In Python, BODMAS rules are also followed naturally due to the operator precedence defined by the language. Here's an example:
result = 5 + 3 * 2 - 4 / 2
print("Result:", result) # Output: 9

Similar to Java and C++, the multiplication and division operations take precedence over addition and subtraction, so they are performed first according to the BOMAS rules.
In all three languages, the BODMAS rules are implicitly followed, ensuring that mathematical expressions are evaluated correctly according to the specified order of operations.








Arithmetic Operators:

Arithmetic operators are used to perform mathematical operations such as addition, subtraction, multiplication, division, and modulus.

Addition (+): Adds two operands.
Subtraction (-): Subtracts the second operand from the first.

Multiplication (*): Multiplies two operands.

Division (/): Divides the first operand by the second.

Modulus (%): Returns the remainder of the division of the first operand by the second.

Bitwise operators

Bitwise operators are used to perform operations on individual bits of integer operands. These operators manipulate the binary representations of numbers. Here are the commonly used bitwise operators:

Bitwise AND (&):
Description: Sets each bit to 1 if both bits are 1.

Bitwise OR (|):
Description: Sets each bit to 1 if either of the corresponding bits is 1.

Bitwise XOR (^):
Description: Sets each bit to 1 if the corresponding bits are different.

Bitwise NOT (~):
Description: Flips the bits of its operand, i.e., changes 1 to 0 and 0 to 1.

Bitwise Left Shift (<<):
Description: Shifts the bits of the left operand to the left by a specified number of positions. Zeros are shifted into the low-order bits.

Bitwise Right Shift (>>):
Description: Shifts the bits of the left operand to the right by a specified number of positions. Zeros are shifted into the high-order bits.


Unary Operators:

Unary operators act on a single operand. Common unary operators include the unary minus (-) ,unary plus (+), increment (++) , decrement(- -).


Comparison Operators:

Comparison operators are used to compare two values. They return either True or False based on the comparison result.
Equal to (==): Returns True if the operands are equal.
Not equal to (!=): Returns True if the operands are not equal.
Greater than (>): Returns True if the left operand is greater than the right.
Less than (<): Returns True if the left operand is less than the right.
Greater than or equal to (>=): Returns True if the left operand is greater than or equal to the right.
Less than or equal to (<=): Returns True if the left operand is less than or equal to the right.


Logical Operators:
Logical operators are used to combine conditional statements. They return True or False based on the conditions.
Logical AND (and): Returns True if both conditions are True.
Logical OR (or): Returns True if at least one condition is True.
Logical NOT (not): Returns the opposite of the condition.

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! 💻✨