Irjet V6i162 PDF
Irjet V6i162 PDF
Irjet V6i162 PDF
---------------------------------------------------------------------***----------------------------------------------------------------------
Display Patterns in java Program 3:
Output
Program 4:
Program 2:
class Pattern4{
class Pattern2{ public static void main(String args[]){
public static void main(String args[]){ for(int i=5;i>=1;i--){
for(int i=1;i<=5;i++){ for(int j=1;j<=i;j++){
for(int j=1;j<=i;j++){ System.out.print("* ");
System.out.print(i); }
} System.out.println();
System.out.println(); }
} }
} }
} Output:
Output:
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 345
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072
Program 5: Program 7:
} else
} c = c*(i-j+1)/j;
System.out.print("\n"); System.out.print(" "+c);
space--; System.out.print("\n");
count = 1; }
} }
} }
}
Output:
Output:
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 347
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072
Output:
Program 15:
class Pattern15{
Program 13: public static void main(String args[]) {
class Pattern13{ int i,j,k,sp=1;
public static void main(String args[]){ for (i=1; i<=5; i++) {
for (int i=1; i<=5; i++) { for (k=sp; k<=5; k++) {
for (int j=5; j>=i; j--) { System.out.print(" ");
System.out.print(" "); }
} for (j=0; j< i; j++) {
for (int k=1; k<=i; k++) { System.out.print("*");
System.out.print("*"); }
} sp = sp + 1;
System.out.print("\n"); System.out.print("\n");
} }
} sp = 1;
} for (i=4; i>=1; i--) {
Output: for (k=sp; k>=0; k--) {
System.out.print(" ");
}
for (j=i; j>=1; j--) {
System.out.print("*");
}
sp = sp + 1;
System.out.print("\n");
}
}
}
Program 14: Output:
class Pattern14{
public static void main(String args[]) {
int i,j,k,sp=1;
for (i=5; i>=1; i--) {
for (k=sp; k>=0; k--) {
System.out.print(" ");// only 1 space
}
for (j=i; j>=1; j--) {
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 348
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072
Program 17:
class Pattern17{
public static void main(String args[]) {
int i,j,k;
for (i=1;i<=5;i++) { Program 19:
for (j=5;j>=1;j--) { class Pattern19{
if(j<=i) public static void main(String args[]) {
System.out.print(j); int i,j,k;
else for (i=1;i<=5;i++) {
System.out.print(" "); j=i;
} for (k=1;k<=i;k++) {
System.out.print("\n"); System.out.print(j++);
} }
} System.out.print("\n");
} }
Output: }
}
Output:
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 349
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072
Program 21:
class Pattern21{
public static void main(String args[]) {
int i,j;
for (i=1;i<=5;i++) {
for (j=1;j<=5;j++) { Program 23:
if(j==5 || j==1 || i==1 || i==5)
System.out.print("1"); class Pattern23{
else public static void main(String args[]) {
System.out.print(" "); int i,j;
} for (i=1;i<=10;i++) {
System.out.print("\n"); for (j=1;j<=i;j++) {
} System.out.print(i*j);
} }
} System.out.print("\n");
}
Output: }
}
Output:
Program 22:
class Pattern22{
public static void main(String args[]) {
int i, j, k;
for (i=1;i<=5;i++) {
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 350
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072
class Pattern24{
public static void main(String args[]) {
int i,j,r,k=1;
r=10;
System.out.print("FLOYD'S TRIANGLE\n\n");
for(i=1;i<=r;i++){
for(j=1;j<=i;j++,k++)
System.out.print(k);
System.out.print("\n");
}
} REFERENCES
}
1. http://scanftree.com/programs/c/programs-
Output: to-print-pyramid-patterns-in-c-part-1/
Program 25:
class Pattern25{
public static void main(String args[]) {
int i, j, rows;
/* Input number of rows from user */
rows=8;
for(i=1; i<=rows; i++) {
/* Print trailing spaces */
for(j=1; j<=rows-i; j++) {
System.out.print(" ");
}
/* Print stars and center spaces */
for(j=1; j<=rows; j++) {
if(i==1 || i==rows || j==1 || j==rows)
System.out.print("*");
else
System.out.print(" ");
}
System.out.print("\n");
}
}
}
© 2019, IRJET | Impact Factor value: 7.211 | ISO 9001:2008 Certified Journal | Page 351