Experiment No:1
package Experiments;
public class Exp1 {
public static void main(String[] args) {
int rows = 4; // Number of rows in the pattern
for (int i = 0; i < rows; i++) {
// Print leading spaces
for (int j = 0; j < i; j++) {
[Link](" ");
// Print stars
for (int j = 0; j < (rows - i); j++) {
[Link]("* ");
// Move to the next line
[Link]();
Output:
Experiment 1(B)
package Experiments;
public class Exp1B {
public static void main(String[] args) {
// Initialize variables
int a = 10, b = 5;
// i) (a << 2) + (b >> 2)
int result1 = (a << 2) + (b >> 2);
// ii) (a) || (b > 0)
boolean result2 = (a != 0) || (b > 0);
// iii) (a + b * 100) / 10
int result3 = (a + b * 100) / 10;
// iv) a & b
int result4 = a & b;
// Display results
[Link]("Result of (a << 2) + (b >> 2): " + result1);
[Link]("Result of (a) || (b > 0): " + result2);
[Link]("Result of (a + b * 100) / 10: " + result3);
[Link]("Result of a & b: " + result4);
Output: