Posts

Showing posts from June, 2024

11. Types of Operator part1

  1.  Arithmetic Operators These are used to perform basic mathematical operations. Addition (+) : Adds two numbers. int a = 5 ; int b = 3 ; int sum = a + b; // sum is 8 Subtraction (-) : Subtracts one number from another. int difference = a - b; // difference is 2 Multiplication (*) : Multiplies two numbers. int product = a * b; // product is 15 Division (/) : Divides one number by another. int quotient = a / b; // quotient is 1 Modulus (%) : Gives the remainder of a division. int remainder = a % b; // remainder is 2 2.   Relational Operators These are used to compare two values. Equal to (==) : Checks if two values are equal. boolean isEqual = (a == b); // isEqual is false Not equal to (!=) : Checks if two values are not equal. boolean isNotEqual = (a != b); // isNotEqual is true Greater than (>) : Checks if one value is greater than another. boolean isGreater = (a > b); // isGreater is true Less than (<) : Checks if one v...