public class ArithmeticDemo{ public static void main(String[] args) { int result; result=-2+5*7-7/2%5; System.out.println(result); }}
Question
public class ArithmeticDemo{ public static void main(String[] args) { int result; result=-2+5*7-7/2%5; System.out.println(result); }}
Solution
No answer
Similar Questions
public class Compute {public static void main (string args [ ]){int result, x ;x = 1 ;result = 0;while (x < = 10) {if (x%2 == 0) result + = x ;+ + x ;}System.out.println(result) ;}}
What is the output of the following code?public class Solution { public static void main(String args[]) { int x = 7--2; System.out.println(x); }}
What will be the output of the following program? int x = 20; int y = 10; double z = x++ - y * 7 / --y + x * 10; System.out.println(z);
Arithmetic OperationsWe can also perform basic mathematical operations with numbers.int a = 6;int b = 3;Use + for addition: System.out.println(a + b); // prints 9Use - for subtraction: System.out.println(a - b); // prints 3Use * for multiplication: System.out.println(a * b); // prints 18Use / (forward slash) for division: System.out.println(a / b); // prints 2Use % (percent symbol, called modulo operator) for the division remainder: System.out.println(a % b); // prints 0 as 6 is evenly divisible by 3Use ++ for increasing the value of a variable by 1: a++; System.out.println(a); // prints 7Use -- for decreasing the value of a variable by 1: b--; System.out.println(b); // prints 2TaskTry printing the sum of 21 and 40.
Select the correct answerWhat will be the output of the following Java code? class CodeTantra { public static void main(String args[]) { try { int x, sum; sum = 7; for (x = -1; x < 4; ++x) { sum = (sum / x); System.out.print(x); } } catch(ArithmeticException e) { System.out.print("0"); } } }Options-1-10-1010
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.