CONTOH PROGRAM NESTED LOOP DALAM BAHASA JAVA
1.SEGITIGA
PASCAL
PROGRAMNYA
:
public
class nestedloop
{
public
static void main (String []args)
{
int
i,j;
for(i=1;i<=5;i++)
{
System.out.print("\n");
for(j=i;j>=1;j--)
{
System.out.print(i+"
");
}
System.out.print("\n");
}
}
}
HASIL
OUTPUT :
2.PERKALIAN
1 HINGGA 10
PROGRAMNYA
:
public class nestedloop1
{
public static void main (String []args)
{
int i,j;
for(i=1;i<=10;i++)
{
System.out.print("\n");
for(j=1;j<=10;j++)
{
System.out.print(j+ "x"+i+
"="+ i*j+(" "));
}
System.out.print("\n");
}
}
}
HASIL
OUTPUT :
Tidak ada komentar:
Posting Komentar