0

How to print the sum of 2 variables x,y

13th Jul 2016, 3:50 PM
Soo Ming Wei
7 Answers
+ 2
variable_type new_variable_name =x+y; System.out.println(new_variable_name);
13th Jul 2016, 3:56 PM
Hiren Namera
Hiren Namera - avatar
+ 1
class Sum { public static void main(String args[]) { int i, j, sum; i = 10; j = 20; sum = i+j; System.out.println("Sum is: " + sum); } } happy to help
15th Jul 2016, 10:00 AM
Dhiman Das
Dhiman Das - avatar
0
May I know what to type after printin
13th Jul 2016, 3:58 PM
Soo Ming Wei
0
in the println() parentheses you have to type the name of the variable you want to display
13th Jul 2016, 8:26 PM
Vamsi Manepalli
Vamsi Manepalli - avatar
0
it depends on what type of x and y.
18th Jul 2016, 1:57 PM
WPimpong
WPimpong - avatar
0
couldn't get this question... anyone can help in taking print
23rd Jul 2016, 4:35 AM
Ashwani Juneja
Ashwani Juneja - avatar
0
class math { int a,b; void add(int x,int y) {a=x; b=y; c=a+b; System.out.println(c); } } class sum { public static void main( String raha[]) {math ob=new math(); ob.add(9,5); }}
18th Aug 2016, 4:40 PM
Suraj Vishwakarma
Suraj Vishwakarma - avatar