public class multiplicationtable {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int x = 2;
int z;
for(int y = 1; y<=10;y++){
z = x * y;
System.out.println(x+" * "+y+ " = "+z);
}
}
}
_____________________________________________
Output:
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
___________________________________________________________
Same way you can change the sign to + or - and create new addition or deduction table.
No comments:
Post a Comment