Java Basic Activities: Assignment Operators



======================
Code: 
======================
public class Test25_Pereda_Challege {

    public static void main(String [] args) {

int a = 5, b = 5;

a +=b;
System.out.println("The sum of the first and second:" + a);
a -=b;
System.out.println("The sum of the first and second:"  + a);
a *=b;
System.out.println("The sum of the first and second:" + a);
a /=b;
System.out.println("The sum of the first and second:"  + a);




    }

}
==============================================

Sample no. 2



=======================
Code: 
=========================
public class Test26_Pereda_Assignment {

public static void main(String [] args) {

int a = 5, c;

c = a;
System.out.println("Variable C is equal to :" + c);
c += a;
System.out.println("Variable C is equal to :" + c);
c -= a;
System.out.println("Variable C is equal to :" + c);
c *= a;
System.out.println("Variable C is equal to :" + c);
c /= a;
System.out.println("Variable C is equal to :" + c);



}

}








Walang komento:

Mag-post ng isang Komento