+ 1
please tell me how can i add two variables
please describe with a example
10 Answers
+ 4
this is another way through which you add 2 variable using only 2 variable
public class addition
{
public static void main(String[] args) {
int a=1 ; int b=2
System.out.println(a+b);
}
}
+ 1
Falk Falk your program is wrong brother
+ 1
@Falkfalk it may run but it is not logically correct
you are adding one variable to a number of your choice which is not the aim,just think if I want to add 8 and 10 how will your program do that?
+ 1
ok so in your program
a=8 b=10 so the answer is 8=5+10 final anger is 15 and 8 plus 10 is not 15
0
int x =2;
int y =3;
int z = x+y;
system.out.println(z);
0
public class Program
{
public static void main(String[] args) {
int a=1 ; int b=2; // two variables declared
int c = a + b; // sum of a & b assigned to c
System.out.println(c);
}
}
0
public class Program
{
public static void main(String[] args) {
int a = 5;
int b = 5 + a;
System.out.println(b);
}
}
0
if i run it it workt
0
int a = 8
int b = a + 10
? i think
0
ok