• Java

    Demonstrate concept of Arithmetic & Bitwise Operators with a java program. Operands to be considered as per the operators entered by the user.

    The below program performs arithmetic and bitwise operations based on number entered by user. Scanner class is used to take input from the user, which is inside java.util.ScannerĀ  class. System.in is used to use input classes. Example import java.util.Scanner; class ArithmeticOperation { //arithmetic operation on float data public static void main(String args[]) { int n1,n2; int fChoice; Scanner sc=new Scanner(System.in); System.out.println("Select Choice\n"); System.out.println("1. Arithmetic Operation"); System.out.println("2. Bitwise Operation"); System.out.println("Enter Your Choice"); fChoice=sc.nextInt(); System.out.println("\nEnter First Value"); n1=sc.nextInt(); System.out.println("Enter Second Value"); n2=sc.nextInt(); switch(fChoice) { case 1: ArithmeticOp(n1,n2); break; case 2: BitwiseOp(n1,n2); break; default: System.out.println("Invalid Choice"); break; } } public static void ArithmeticOp(int…

  • PHP

    Arithmetic, Logical And Comparison Operation

    Here, Dot(.) is used to concate the statements. <br> tag is used to break the line. <?php $a=10; $b=20; echo "Value of a = $a"."<br>"; echo "Value of b = $b"."<br>"; echo "<br> ***Arithmetic Operator*** <br>"; $c=$a+$b; echo "Addition of $a and $b = $c"."<br>"; $c=$a-$b; echo "Subtraction of $a and $b = $c"."<br>"; $c=$a*$b; echo "Multiplication of $a and $b = $c"."<br>"; $c=$a/$b; echo "Division of $a and $b = $c"."<br>"; echo "<br> ***Comparison Operator*** <br>"; if($a>$b) { echo "$a is greater than $b <br>"; } else if($a<$b) { echo "$a is less then $b <br>"; } else if($a==$b)…