Monday 23 March 2020

EXCHANGE VALUES USING JAVA LANGUAGE

Q-7-Write a java program to exchange the values of two variables of integer type A and B using third temporary variable C. 
INPUT :
public class NCM {

public static void main(String[] args) {
// TODO Auto-generated method stub
int a=10;
int b=20;
int c ;
c=a;
a=b;
b=c;
System.out.println(a);
System.out.println(b);
}


}

OUTPUT :
20
10

No comments:

Post a Comment