+ 1

please tell me how can i add two variables

please describe with a example

8th Oct 2016, 10:28 AM
Shatrughan Tyagi
Shatrughan  Tyagi - avatar
10 Réponses
+ 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); } }
8th Oct 2016, 3:40 PM
Mankrit Singh
Mankrit Singh - avatar
+ 1
Falk Falk your program is wrong brother
17th Oct 2016, 2:21 PM
Mankrit Singh
Mankrit Singh - avatar
+ 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?
17th Oct 2016, 2:30 PM
Mankrit Singh
Mankrit Singh - avatar
+ 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
17th Oct 2016, 2:36 PM
Mankrit Singh
Mankrit Singh - avatar
0
int x =2; int y =3; int z = x+y; system.out.println(z);
8th Oct 2016, 11:39 AM
jerry
jerry - avatar
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); } }
8th Oct 2016, 12:09 PM
Yassine Iguider
Yassine Iguider - avatar
0
public class Program { public static void main(String[] args) { int a = 5; int b = 5 + a; System.out.println(b); } }
17th Oct 2016, 2:19 PM
Nils Birkemeyer
Nils Birkemeyer - avatar
0
if i run it it workt
17th Oct 2016, 2:25 PM
Nils Birkemeyer
Nils Birkemeyer - avatar
0
int a = 8 int b = a + 10 ? i think
17th Oct 2016, 2:33 PM
Nils Birkemeyer
Nils Birkemeyer - avatar
0
ok
17th Oct 2016, 2:40 PM
Nils Birkemeyer
Nils Birkemeyer - avatar