Sample Code
Squares
public class Triangle
{
public static void main (String args [])
{
for(int i=0;i<5;i++)
{
for (int j = 0; j<i; j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
Table Square
public class nest1
{
public static void main (String args [])
{
for(int i = 1; i<4; i++)
{
for(int j = 1; j<4; j++)
{
System.out.println(i + " x " + j + " = " + i*j );
}
}
}
}
Exercise
- Print out the following shapes: \/ \/\/ \/\/\/ \/\/\/\/ \/\/\/\/\/
- Print out the following 54321 4321 321 21 1
- Print out the following shapes \*/ \**/ \***/ \****/ \*****/
- Print out a 10 x 10 table square
- Print out the following shapes \/ \\// \\\/// \\\\//// \\\\\/////
- Print out an 8 x 8 chessboard. Use * for black and – for white
- Print out the following shapes:
* ** ** *** *** *** **** **** **** **** ***** ***** ***** ***** *****