Posts

Showing posts from May, 2026

New soham

 #include <stdio.h> #include <stdlib.h> #define MAX 20 charstk[20]; int top = -1; int isEmpty(){ return top == -1; } int isFull(){ return top == MAX - 1; } char peek(){ return stk[top]; } char pop(){ if(isEmpty()) return -1; char ch = stk[top]; top--; return(ch); } void push(char oper){ if(isFull()) printf("Stack Full!!!!"); else{ top++; stk[top] = oper; } } int checkIfOperand(char ch) { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); } int precedence(char ch) { switch (ch) { case '+': case '-': return 1; case '*': case '/': return 2; case '^': return 3; } return -1; } int covertInfixToPostfix(char* expression) { int i, j; for (i = 0, j = -1; expression[i]; ++i) { if (checkIfOperand(expression[i])) expression[++j] = expression[i]; else if (expression[i] == '(') push(expression[i]); else if (expressi...

Soham

 public class NumberTriangle {  public static void main(String[] args) {  int n = 5; // Number of rows in the triangle  for (int i = 1; i <= n; i++) { // Loop for each row  for (int j = 1; j <= i; j++) { // Loop to print numbers in each row  System.out.print(j + " ");  }  System.out.println(); // Move to the next line after printing each row  }  } } public class FactorialList {  public static void main(String[] args) {  int number = 1; // Start with the number 1 while (number <= 10) { // Loop through numbers from 1 to 10  int factorial = 1;  int i = number;  // Calculate factorial using a while loop  while (i > 0) {  factorial *= i;  i--;  }  // Print the factorial of the current number  System.out.println("Factorial of " + number + " = " + factorial);  number++; // Move to the next number  }  } } public class DivisionByZeroDemo {  p...