+ 2

How to print the sum of the two variables?

INT x=2, INT y=4; INT result =x__ __; system.out.println();

19th Dec 2016, 6:41 AM
Mohammed Zubair
Mohammed Zubair - avatar
5 Respuestas
+ 7
@Rayachoti Ravi. no need + sign
26th Dec 2016, 7:28 AM
Kara
Kara - avatar
+ 6
int x=2, int y=5; int res =x+y; System.out.println("Sum of x and y :"+res );
21st Dec 2016, 5:54 PM
Kara
Kara - avatar
+ 3
You got two variables, x and y. The sum operator is +, and the total sum is stored in another variable, named result. Finally, you have to print this variable 'result', by placing the variable inside the parentheses of println.
19th Dec 2016, 6:44 AM
Álvaro
+ 2
thanks Alvaro
19th Dec 2016, 6:45 AM
Mohammed Zubair
Mohammed Zubair - avatar
0
int result=x+y; system. out.println(+result);
19th Dec 2016, 4:35 PM
Rayachoti Ravi
Rayachoti Ravi - avatar