0
How to print the sum of 2 variables x,y
7 Answers
+ 2
variable_type new_variable_name =x+y;
System.out.println(new_variable_name);
+ 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
0
May I know what to type after printin
0
in the println() parentheses you have to type the name of the variable you want to display
0
it depends on what type of x and y.
0
couldn't get this question... anyone can help in taking print
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);
}}