0

What is wrong in this coding

class swap <static void main(); <int a=10; int b=20: a=20*1: b=20/10: system.out.println(""the number after swapping a=""+a); system.out.println("the number after swapping b="+b);>>

27th Jul 2020, 11:21 AM
Shaswat Prajapati
Shaswat Prajapati - avatar
1 Antwort
0
You can use a temporary variable to swap.Also 20/10 does not give 10 it gives 2. int a,b,temp; //take input from user temp=a; a=b; b=temp; try this
27th Jul 2020, 12:08 PM
Praharsh Gurudatta
Praharsh Gurudatta - avatar